clk: Fix incorrect rate comparison in clk_set_rate()
PATCH 1/1 clk: Fix incorrect rate comparison in clk_set_rate()
The original condition in clk_set_rate() compared the current clock rate against clk_round_rate(clk, rate). However, when the clock driver doesn't implement .round_rate(), clk_round_rate() falls back to returning the current clock rate via clk_get_rate(). This created a situation where:clk_get_rate(clk) == clk_round_rate(clk, rate)
would always evaluate to true when .round_rate() is unimplemented.
--- drivers/clk/clk.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/clk/clk.c +2 -1
@@ -169,7 +169,8 @@ int clk_set_rate(struct clk *clk, unsigned long rate)if (IS_ERR (clk))return PTR_ERR (clk); -if (clk_get_rate (clk) ==clk_round_rate (clk, rate)) +if (clk_get_rate (clk) == + (clk->ops->round_rate ?clk_round_rate (clk, rate) : rate))return 0 ;if (!clk->ops->set_rate)
Signature · 1 line
2.39.1
Sascha Hauer
AppliedQuoted 8 lines · Alexander Shiyan
The original condition in
clk_set_rate()compared the current clock rate againstclk_round_rate(clk, rate). However, when the clock driver doesn't implement .round_rate(),clk_round_rate()falls back to returning the current clock rate viaclk_get_rate(). This created a situation where:clk_get_rate(clk)==clk_round_rate(clk, rate)
would always evaluate to true when .round_rate() is unimplemented.[...]
Applied, thanks!
[1/1] clk: Fix incorrect rate comparison in clk_set_rate()
https://git.pengutronix.de/cgit/barebox/commit/?id=3111d62b3174 (link may not be stable)
Best regards,
Signature · 1 line
Sascha Hauer <[email protected]>