diff options
author | Emil Renner Berthing <kernel@esmil.dk> | 2022-01-26 18:39:47 +0100 |
---|---|---|
committer | Stephen Boyd <sboyd@kernel.org> | 2022-03-10 18:17:32 -0800 |
commit | 40dda3532f903107a063cd6ec1f15e10dd0eccc5 (patch) | |
tree | 4042610f551d5e6fc570d453992797d4932233ee /lib/mpi/mpi-mod.c | |
parent | e783362eb54cd99b2cac8b3a9aeac942e6f6ac07 (diff) |
clk: starfive: jh7100: Don't round divisor up twice
The problem is best illustrated by an example. Suppose a consumer wants
a 4MHz clock rate from a divider with a 10MHz parent. It would then
call
clk_round_rate(clk, 4000000)
which would call into our determine_rate() callback that correctly
rounds up and finds that a divisor of 3 gives the highest possible
frequency below the requested 4MHz and returns 10000000 / 3 = 3333333Hz.
However the consumer would then call
clk_set_rate(clk, 3333333)
but since 3333333 doesn't divide 10000000 evenly our set_rate() callback
would again round the divisor up and set it to 4 which results in an
unnecessarily low rate of 2.5MHz.
Fix it by using DIV_ROUND_CLOSEST in the set_rate() callback.
Fixes: 4210be668a09 ("clk: starfive: Add JH7100 clock generator driver")
Signed-off-by: Emil Renner Berthing <kernel@esmil.dk>
Link: https://lore.kernel.org/r/20220126173953.1016706-2-kernel@esmil.dk
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
Diffstat (limited to 'lib/mpi/mpi-mod.c')
0 files changed, 0 insertions, 0 deletions