Skip to content

Commit 576418e

Browse files
bijudasbebarino
authored andcommitted
clk: vc3: Fix 64 by 64 division
Fix the below cocci warnings by replacing do_div()->div64_ul() and bound the result with a max value of U16_MAX. cocci warnings: drivers/clk/clk-versaclock3.c:404:2-8: WARNING: do_div() does a 64-by-32 division, please consider using div64_ul instead. Reported-by: Julia Lawall <[email protected]> Closes: https://lore.kernel.org/r/[email protected]/ Fixes: 6e9aff5 ("clk: Add support for versa3 clock driver") Signed-off-by: Biju Das <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Stephen Boyd <[email protected]>
1 parent 1aa2a9f commit 576418e

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

drivers/clk/clk-versaclock3.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -401,11 +401,10 @@ static long vc3_pll_round_rate(struct clk_hw *hw, unsigned long rate,
401401
/* Determine best fractional part, which is 16 bit wide */
402402
div_frc = rate % *parent_rate;
403403
div_frc *= BIT(16) - 1;
404-
do_div(div_frc, *parent_rate);
405404

406-
vc3->div_frc = (u32)div_frc;
405+
vc3->div_frc = min_t(u64, div64_ul(div_frc, *parent_rate), U16_MAX);
407406
rate = (*parent_rate *
408-
(vc3->div_int * VC3_2_POW_16 + div_frc) / VC3_2_POW_16);
407+
(vc3->div_int * VC3_2_POW_16 + vc3->div_frc) / VC3_2_POW_16);
409408
} else {
410409
rate = *parent_rate * vc3->div_int;
411410
}

0 commit comments

Comments
 (0)