* [PATCH] clk: hisilicon: use div64_u64() instead of do_div()
@ 2022-02-09 8:35 Qing Wang
0 siblings, 0 replies; only message in thread
From: Qing Wang @ 2022-02-09 8:35 UTC (permalink / raw)
To: Michael Turquette, Stephen Boyd, linux-clk, linux-kernel; +Cc: Wang Qing
From: Wang Qing <wangqing@vivo.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@vivo.com>
---
drivers/clk/hisilicon/clk-hi3559a.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/clk/hisilicon/clk-hi3559a.c b/drivers/clk/hisilicon/clk-hi3559a.c
index 56012a3d..8e90598
--- a/drivers/clk/hisilicon/clk-hi3559a.c
+++ b/drivers/clk/hisilicon/clk-hi3559a.c
@@ -441,8 +441,8 @@ static unsigned long clk_pll_recalc_rate(struct clk_hw *hw,
rate = 0;
tmp = 24000000 * fbdiv_val + (24000000 * frac_val) / (1 << 24);
rate += tmp;
- do_div(rate, refdiv_val);
- do_div(rate, postdiv1_val * postdiv2_val);
+ div64_u64(rate, refdiv_val);
+ div64_u64(rate, postdiv1_val * postdiv2_val);
return rate;
}
--
2.7.4
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-02-09 8:36 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-09 8:35 [PATCH] clk: hisilicon: use div64_u64() instead of do_div() Qing Wang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®