All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] clk: Disambiguate comment about clk_get_rate() for disabled clocks
@ 2023-02-01  8:23 Uwe Kleine-König
  2023-02-09 15:57 ` Russell King (Oracle)
  0 siblings, 1 reply; 4+ messages in thread
From: Uwe Kleine-König @ 2023-02-01  8:23 UTC (permalink / raw)
  To: Russell King; +Cc: Stephen Boyd, Michael Turquette, kernel, linux-clk

The sentence "[clk_get_rate()] is only valid once the clock source has
been enabled." can be understood in two ways:

a) When called for a disabled clock the return value might be wrong; or
b) The disabled clock must be enabled before it runs at the returned
rate.

It's hard to find evidence what is actually meant, but given that the
clock tree can change between the call to clk_get_rate() and the return
of a later clk_enable() call, it's prudent to assume a).

Adapt the comment accordingly to be unambiguous.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
Hello,

while archiving my old mail I stumbled over
https://lore.kernel.org/linux-clk/20210213165406.GQ1463@shell.armlinux.org.uk
which supports semantic a).

Clearify the documentation accordingly.

Best regards
Uwe

 include/linux/clk.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/include/linux/clk.h b/include/linux/clk.h
index 1ef013324237..72f90d4df433 100644
--- a/include/linux/clk.h
+++ b/include/linux/clk.h
@@ -676,8 +676,10 @@ void clk_bulk_disable(int num_clks, const struct clk_bulk_data *clks);
 
 /**
  * clk_get_rate - obtain the current clock rate (in Hz) for a clock source.
- *		  This is only valid once the clock source has been enabled.
  * @clk: clock source
+ *
+ * Note that the return value for disabled clks is unreliable. It might or
+ * might not match the actual rate of the clock once it's enabled.
  */
 unsigned long clk_get_rate(struct clk *clk);
 

base-commit: 58706f7fb045b7019bada81fa17f372189315fe5
-- 
2.39.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-04-06  9:27 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-01  8:23 [PATCH] clk: Disambiguate comment about clk_get_rate() for disabled clocks Uwe Kleine-König
2023-02-09 15:57 ` Russell King (Oracle)
2023-02-14  9:06   ` Uwe Kleine-König
2023-04-06  9:26     ` Uwe Kleine-König

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.