[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1644395998-4397-1-git-send-email-wangqing@vivo.com>
Date: Wed, 9 Feb 2022 00:39:58 -0800
From: Qing Wang <wangqing@...o.com>
To: Thierry Reding <thierry.reding@...il.com>,
Uwe Kleine-König
<u.kleine-koenig@...gutronix.de>, Lee Jones <lee.jones@...aro.org>,
linux-pwm@...r.kernel.org, linux-kernel@...r.kernel.org
Cc: Wang Qing <wangqing@...o.com>
Subject: [PATCH] pwm: use div64_u64() instead of do_div()
From: Wang Qing <wangqing@...o.com>
do_div() does a 64-by-32 division.
When the divisor is u64, do_div() truncates it to 32 bits, this means it
can test non-zero and be truncated to zero for division.
fix do_div.cocci warning:
do_div() does a 64-by-32 division, please consider using div64_u64 instead.
Signed-off-by: Wang Qing <wangqing@...o.com>
---
drivers/pwm/pwm-berlin.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/pwm/pwm-berlin.c b/drivers/pwm/pwm-berlin.c
index e157273..15b10cb3
--- a/drivers/pwm/pwm-berlin.c
+++ b/drivers/pwm/pwm-berlin.c
@@ -109,7 +109,7 @@ static int berlin_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
period = cycles;
cycles *= duty_ns;
- do_div(cycles, period_ns);
+ div64_u64(cycles, period_ns);
duty = cycles;
value = berlin_pwm_readl(bpc, pwm->hwpwm, BERLIN_PWM_CONTROL);
--
2.7.4
Powered by blists - more mailing lists