Skip to content

Commit cc26ed7

Browse files
Dinh Nguyenbebarino
authored andcommitted
clk: stratix10: use do_div() for 64-bit calculation
do_div() macro to perform u64 division and guards against overflow if the result is too large for the unsigned long return type. Signed-off-by: Dinh Nguyen <[email protected]> Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Stephen Boyd <[email protected]>
1 parent bb6d3fb commit cc26ed7

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

drivers/clk/socfpga/clk-pll-s10.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ static unsigned long clk_pll_recalc_rate(struct clk_hw *hwclk,
3939
/* read VCO1 reg for numerator and denominator */
4040
reg = readl(socfpgaclk->hw.reg);
4141
refdiv = (reg & SOCFPGA_PLL_REFDIV_MASK) >> SOCFPGA_PLL_REFDIV_SHIFT;
42-
vco_freq = (unsigned long long)parent_rate / refdiv;
42+
43+
vco_freq = parent_rate;
44+
do_div(vco_freq, refdiv);
4345

4446
/* Read mdiv and fdiv from the fdbck register */
4547
reg = readl(socfpgaclk->hw.reg + 0x4);

0 commit comments

Comments
 (0)