Skip to content

Commit b467e08

Browse files
Icenowymripard
authored andcommitted
clk: sunxi-ng: fix recalc_rate formula of NKMP clocks
In commit e66f81b ("clk: sunxi-ng: Implement factors offsets"), the final formula of NKMP clocks' recalc_rate is refactored; however, the refactored formula broke the calculation due to some C language operand priority problem -- the priority of operand >> is lower than * and /, makes the formula being parsed as "(parent_rate * n * k) >> (p / m)", but it should be "(parent_rate * n * k >> p) / m". Add the pair of parentheses to fix up this issue. This pair of parentheses used to exist in the old formula. Fixes: e66f81b ("clk: sunxi-ng: Implement factors offsets") Signed-off-by: Icenowy Zheng <[email protected]> Signed-off-by: Maxime Ripard <[email protected]>
1 parent fe686ba commit b467e08

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/clk/sunxi-ng/ccu_nkmp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ static unsigned long ccu_nkmp_recalc_rate(struct clk_hw *hw,
107107
p = reg >> nkmp->p.shift;
108108
p &= (1 << nkmp->p.width) - 1;
109109

110-
return parent_rate * n * k >> p / m;
110+
return (parent_rate * n * k >> p) / m;
111111
}
112112

113113
static long ccu_nkmp_round_rate(struct clk_hw *hw, unsigned long rate,

0 commit comments

Comments
 (0)