* [PATCH] clk: Fix incorrect rate comparison in clk_set_rate()
@ 2025-04-28 9:25 Alexander Shiyan
0 siblings, 0 replies; only message in thread
From: Alexander Shiyan @ 2025-04-28 9:25 UTC (permalink / raw)
To: barebox; +Cc: Alexander Shiyan
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.
Signed-off-by: Alexander Shiyan <eagle.alexander923@gmail.com>
---
drivers/clk/clk.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index bd36878280..8ecfe35094 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -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)
--
2.39.1
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2025-04-28 9:40 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-04-28 9:25 [PATCH] clk: Fix incorrect rate comparison in clk_set_rate() Alexander Shiyan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox