lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20220408100721.rinvvgard3nr5wff@pengutronix.de>
Date:   Fri, 8 Apr 2022 12:07:21 +0200
From:   Uwe Kleine-König <u.kleine-koenig@...gutronix.de>
To:     Wan Jiabing <wanjiabing@...o.com>
Cc:     Thierry Reding <thierry.reding@...il.com>,
        Lee Jones <lee.jones@...aro.org>,
        Palmer Dabbelt <palmer@...belt.com>,
        Paul Walmsley <paul.walmsley@...ive.com>,
        linux-pwm@...r.kernel.org, linux-riscv@...ts.infradead.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH] pwm: sifive: simplify if-if to if-else

On Fri, Apr 08, 2022 at 04:30:07PM +0800, Wan Jiabing wrote:
> use if and else instead of if(A) and if (!A).
> 
> Signed-off-by: Wan Jiabing <wanjiabing@...o.com>
> ---
>  drivers/pwm/pwm-sifive.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/pwm/pwm-sifive.c b/drivers/pwm/pwm-sifive.c
> index 253c4a17d255..e6d05a329002 100644
> --- a/drivers/pwm/pwm-sifive.c
> +++ b/drivers/pwm/pwm-sifive.c
> @@ -138,10 +138,9 @@ static int pwm_sifive_enable(struct pwm_chip *chip, bool enable)
>  			dev_err(ddata->chip.dev, "Enable clk failed\n");
>  			return ret;
>  		}
> -	}
> -
> -	if (!enable)
> +	} else {
>  		clk_disable(ddata->clk);
> +	}
>  
>  	return 0;
>  }

The patch looks fine. I wonder if it would be sensible to clean up even
more: pwm_sifive_apply() is only a single caller of
pwm_sifive_enable(). If this is optimized to skip the duty_cycle and
period calculation for the state->enabled = false case and just disables
the clock this should still work.

Also I wonder if there is a clk mismatch issue in this driver: .probe
enables the clk and if the PWM is off (i.e. .get_state diagnoses that)
the clock will never be disabled while the driver is bound, will it?

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | https://www.pengutronix.de/ |

Download attachment "signature.asc" of type "application/pgp-signature" (489 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ