Thread (17 messages) 17 messages, 8 authors, 2014-08-27
STALE4296d
Revisions (23)
  1. v4 [diff vs current]
  2. v5 [diff vs current]
  3. v6 [diff vs current]
  4. v7 current
  5. v8 [diff vs current]
  6. v9 [diff vs current]
  7. v10 [diff vs current]
  8. v11 [diff vs current]
  9. v12 [diff vs current]
  10. v13 [diff vs current]
  11. v1 [diff vs current]
  12. v2 [diff vs current]
  13. v3 [diff vs current]
  14. v4 [diff vs current]
  15. v5 [diff vs current]
  16. v6 [diff vs current]
  17. v7 [diff vs current]
  18. v8 [diff vs current]
  19. v9 [diff vs current]
  20. v10 [diff vs current]
  21. v11 [diff vs current]
  22. v12 [diff vs current]
  23. v13 [diff vs current]

[PATCH v7 2/8] clk: provide public clk_is_enabled function

From: Tomeu Vizoso <hidden>
Date: 2014-08-18 15:32:47
Also in: lkml
Subsystem: clk api, common clk framework, the rest · Maintainers: Russell King, Michael Turquette, Stephen Boyd, Linus Torvalds

From: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>

To determine if a clk has been previously enabled, provide a public
clk_is_enabled function. This is especially helpful to check the state
of clk-gate without actually changing the state of the gate.

Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
Signed-off-by: Tomeu Vizoso <redacted>
---
 drivers/clk/clk.c   | 18 ++++++++++++++++++
 include/linux/clk.h | 13 +++++++++++++
 2 files changed, 31 insertions(+)
diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index b76fa69..bf46d27 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -953,6 +953,24 @@ int clk_enable(struct clk *clk)
 EXPORT_SYMBOL_GPL(clk_enable);
 
 /**
+ * clk_is_enabled - return the enabled state of a clk
+ * @clk: the clk whose enabled state gets returned
+ *
+ * Returns true if the clock is enabled, false otherwise.
+ */
+bool clk_is_enabled(struct clk *clk)
+{
+	bool is_en;
+
+	clk_prepare_lock();
+	is_en = __clk_is_enabled(clk);
+	clk_prepare_unlock();
+
+	return is_en;
+}
+EXPORT_SYMBOL_GPL(clk_is_enabled);
+
+/**
  * __clk_round_rate - round the given rate for a clk
  * @clk: round the rate of this clock
  * @rate: the rate which is to be rounded
diff --git a/include/linux/clk.h b/include/linux/clk.h
index fb5e097..2cd8d3c 100644
--- a/include/linux/clk.h
+++ b/include/linux/clk.h
@@ -218,6 +218,14 @@ int clk_enable(struct clk *clk);
 void clk_disable(struct clk *clk);
 
 /**
+ * clk_is_enabled - return the enabled state of a clk
+ * @clk: the clk whose enabled state gets returned
+ *
+ * Returns true if the clock is enabled, false otherwise.
+ */
+bool clk_is_enabled(struct clk *clk);
+
+/**
  * 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
@@ -330,6 +338,11 @@ static inline int clk_enable(struct clk *clk)
 
 static inline void clk_disable(struct clk *clk) {}
 
+static inline bool clk_is_enabled(struct clk *clk)
+{
+	return false;
+}
+
 static inline unsigned long clk_get_rate(struct clk *clk)
 {
 	return 0;
-- 
1.9.3
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help