Thread (128 messages) 128 messages, 19 authors, 2011-04-20
STALE5580d

[RFC, PATCH 3/3] clk: add warnings for incorrect enable/prepare semantics

From: Jeremy Kerr <hidden>
Date: 2011-02-07 06:09:00
Also in: linux-sh, lkml
Subsystem: common clk framework, the rest · Maintainers: Michael Turquette, Stephen Boyd, Linus Torvalds

This change adds warnings to check for:

 1) enabling a clock that hasn't been prepared; and

 2) unpreparing a clock that is still enabled

While the correctness can't be guaranteed, these warnings should cover
most situations.

Signed-off-by: Jeremy Kerr <redacted>

---
 drivers/clk/clk.c |    4 ++++
 1 file changed, 4 insertions(+)
diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index 51dbd33..2369959 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -35,6 +35,8 @@ void clk_unprepare(struct clk *clk)
 	if (!clk->ops->unprepare)
 		return;
 
+	WARN_ON(clk->enable_count);
+
 	mutex_lock(&clk->prepare_lock);
 	if (--clk->prepare_count == 0)
 		clk->ops->unprepare(clk);
@@ -50,6 +52,8 @@ int clk_enable(struct clk *clk)
 	if (!clk->ops->enable)
 		return 0;
 
+	WARN_ON(clk->ops->prepare && clk->prepare_count);
+
 	spin_lock(&clk->enable_lock);
 	if (!clk->enable_count)
 		ret = clk->ops->enable(clk);
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help