Skip to content

Commit c1b6ad9

Browse files
Changcheng Dengabelvesa
authored andcommitted
clk: imx: Use div64_ul instead of do_div
do_div() does a 64-by-32 division. Here the divisor is an unsigned long which on some platforms is 64 bit wide. So use div64_ul instead of do_div to avoid a possible truncation. Reported-by: Zeal Robot <[email protected]> Signed-off-by: Changcheng Deng <[email protected]> Reviewed-by: Abel Vesa <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Abel Vesa <[email protected]>
1 parent b5e29cf commit c1b6ad9

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

drivers/clk/imx/clk-pllv3.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ static long clk_pllv3_av_round_rate(struct clk_hw *hw, unsigned long rate,
247247
div = rate / parent_rate;
248248
temp64 = (u64) (rate - div * parent_rate);
249249
temp64 *= mfd;
250-
do_div(temp64, parent_rate);
250+
temp64 = div64_ul(temp64, parent_rate);
251251
mfn = temp64;
252252

253253
temp64 = (u64)parent_rate;
@@ -277,7 +277,7 @@ static int clk_pllv3_av_set_rate(struct clk_hw *hw, unsigned long rate,
277277
div = rate / parent_rate;
278278
temp64 = (u64) (rate - div * parent_rate);
279279
temp64 *= mfd;
280-
do_div(temp64, parent_rate);
280+
temp64 = div64_ul(temp64, parent_rate);
281281
mfn = temp64;
282282

283283
val = readl_relaxed(pll->base);
@@ -334,7 +334,7 @@ static struct clk_pllv3_vf610_mf clk_pllv3_vf610_rate_to_mf(
334334
/* rate = parent_rate * (mfi + mfn/mfd) */
335335
temp64 = rate - parent_rate * mf.mfi;
336336
temp64 *= mf.mfd;
337-
do_div(temp64, parent_rate);
337+
temp64 = div64_ul(temp64, parent_rate);
338338
mf.mfn = temp64;
339339
}
340340

0 commit comments

Comments
 (0)