linux-clk.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* clk_get_rate for disabled clks
@ 2020-12-21  9:27 Uwe Kleine-König
  2020-12-21 12:57 ` Marc Kleine-Budde
  2021-01-13  8:30 ` [PATCH] clk: Warn when clk_get_rate is called for a disabled clk Uwe Kleine-König
  0 siblings, 2 replies; 9+ messages in thread
From: Uwe Kleine-König @ 2020-12-21  9:27 UTC (permalink / raw)
  To: Michael Turquette, Stephen Boyd; +Cc: linux-clk, Simon South, kernel

[-- Attachment #1: Type: text/plain, Size: 1002 bytes --]

Hello,

the documentation about clk_get_rate in include/linux/clk.h reads:

	[...] obtain the current clock rate (in Hz) for a clock source.
	This is only valid once the clock source has been enabled.

The second part isn't enforced and (I think) there are many consumers
who don't ensure the clock being enabled. (I just stumbled over
rockchip_pwm_get_state().)

I wonder if it would be sensible to add a development check to
clk_get_rate, something like:

	if (WARN(!clk->usecount, "Trying to get rate of a disabled clk"))
		return 0;

(or something less consequent like not returning 0 but the value it also
returns today). Or is the statement in the comment wrong today and it
can be assumed that clk_get_rate() also works for a disabled clock (and
yields the rate it would have were it enabled)?

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | https://www.pengutronix.de/ |

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

end of thread, other threads:[~2021-11-12  8:49 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-21  9:27 clk_get_rate for disabled clks Uwe Kleine-König
2020-12-21 12:57 ` Marc Kleine-Budde
2021-01-13  8:30 ` [PATCH] clk: Warn when clk_get_rate is called for a disabled clk Uwe Kleine-König
2021-02-11  3:14   ` Stephen Boyd
2021-02-11  8:05     ` Uwe Kleine-König
2021-02-13  1:14       ` Stephen Boyd
2021-02-13 16:54         ` Russell King - ARM Linux admin
2021-11-12  8:34           ` Uwe Kleine-König
2021-11-12  8:49             ` Marc Kleine-Budde

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).