[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20211117145419.b4wb6zp42rjdpgn5@pengutronix.de>
Date: Wed, 17 Nov 2021 15:54:19 +0100
From: Uwe Kleine-König <u.kleine-koenig@...gutronix.de>
To: cgel.zte@...il.com
Cc: alexandre.belloni@...tlin.com, deng.changcheng@....com.cn,
lee.jones@...aro.org, linux-arm-kernel@...ts.infradead.org,
linux-kernel@...r.kernel.org, linux-pwm@...r.kernel.org,
ludovic.desroches@...rochip.com, nicolas.ferre@...rochip.com,
thierry.reding@...il.com, zealci@....com.cn
Subject: Re: [PATCH V2] pwm: Use div64_ul instead of do_div
On Wed, Nov 17, 2021 at 12:46:53PM +0000, cgel.zte@...il.com wrote:
> From: Changcheng Deng <deng.changcheng@....com.cn>
>
> do_div() does a 64-by-32 division. If the divisor is unsigned long, using
> div64_ul can avoid truncation to 32-bit.
>
> Reported-by: Zeal Robot <zealci@....com.cn>
> Signed-off-by: Changcheng Deng <deng.changcheng@....com.cn>
> ---
> drivers/pwm/pwm-atmel-hlcdc.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/pwm/pwm-atmel-hlcdc.c b/drivers/pwm/pwm-atmel-hlcdc.c
> index a43b2babc809..1ae3d73b9832 100644
> --- a/drivers/pwm/pwm-atmel-hlcdc.c
> +++ b/drivers/pwm/pwm-atmel-hlcdc.c
> @@ -60,7 +60,7 @@ static int atmel_hlcdc_pwm_apply(struct pwm_chip *c, struct pwm_device *pwm,
> return -EINVAL;
>
> clk_period_ns = (u64)NSEC_PER_SEC * 256;
> - do_div(clk_period_ns, clk_freq);
> + clk_period_ns = div64_ul(clk_period_ns, clk_freq);
> }
>
> /* Errata: cannot use slow clk on some IP revisions */
> @@ -72,7 +72,7 @@ static int atmel_hlcdc_pwm_apply(struct pwm_chip *c, struct pwm_device *pwm,
> return -EINVAL;
>
> clk_period_ns = (u64)NSEC_PER_SEC * 256;
> - do_div(clk_period_ns, clk_freq);
> + clk_period_ns = div64_ul(clk_period_ns, clk_freq);
The code change is good now, the commit log is as confusing as in v1.
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