All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 1/2] clk: Add consumer APIs for discovering possible parent clocks
@ 2016-06-16  6:21 Scott Wood
  2016-06-16  6:21 ` [PATCH v3 2/2] cpufreq: qoriq: Don't look at clock implementation details Scott Wood
  2016-06-29  5:50   ` Yuantian Tang
  0 siblings, 2 replies; 28+ messages in thread
From: Scott Wood @ 2016-06-16  6:21 UTC (permalink / raw)
  To: Russell King, Michael Turquette, Stephen Boyd, Viresh Kumar,
	Rafael J. Wysocki
  Cc: linux-clk, linux-pm, linuxppc-dev, yuantian.tang, leoyang.li,
	xiaofeng.ren, Scott Wood

From: Scott Wood <scottwood@freescale.com>

Commit fc4a05d4b0eb ("clk: Remove unused provider APIs") removed
__clk_get_num_parents() and clk_hw_get_parent_by_index(), leaving only
true provider API versions that operate on struct clk_hw.

qoriq-cpufreq needs these functions in order to determine the options
it has for calling clk_set_parent() and thus populate the cpufreq
table, so revive them as legitimate consumer APIs.

Signed-off-by: Scott Wood <scottwood@freescale.com>
---
v2: Add missing 'static inline' to stub functions.

v3: no changes

 drivers/clk/clk.c   | 19 +++++++++++++++++++
 include/linux/clk.h | 31 +++++++++++++++++++++++++++++++
 2 files changed, 50 insertions(+)

diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index d584004..d61a3fe 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -290,6 +290,12 @@ struct clk_hw *__clk_get_hw(struct clk *clk)
 }
 EXPORT_SYMBOL_GPL(__clk_get_hw);
 
+unsigned int clk_get_num_parents(struct clk *clk)
+{
+	return !clk ? 0 : clk->core->num_parents;
+}
+EXPORT_SYMBOL_GPL(clk_get_num_parents);
+
 unsigned int clk_hw_get_num_parents(const struct clk_hw *hw)
 {
 	return hw->core->num_parents;
@@ -358,6 +364,19 @@ static struct clk_core *clk_core_get_parent_by_index(struct clk_core *core,
 	return core->parents[index];
 }
 
+struct clk *clk_get_parent_by_index(struct clk *clk, unsigned int index)
+{
+	struct clk_core *parent;
+
+	if (!clk)
+		return NULL;
+
+	parent = clk_core_get_parent_by_index(clk->core, index);
+
+	return !parent ? NULL : parent->hw->clk;
+}
+EXPORT_SYMBOL_GPL(clk_get_parent_by_index);
+
 struct clk_hw *
 clk_hw_get_parent_by_index(const struct clk_hw *hw, unsigned int index)
 {
diff --git a/include/linux/clk.h b/include/linux/clk.h
index 0df4a51..acd115f 100644
--- a/include/linux/clk.h
+++ b/include/linux/clk.h
@@ -392,6 +392,26 @@ int clk_set_parent(struct clk *clk, struct clk *parent);
 struct clk *clk_get_parent(struct clk *clk);
 
 /**
+ * clk_get_parent_by_index - get a possible parent clock by index
+ * @clk: clock source
+ * @index: index into the array of possible parents of this clock
+ *
+ * Returns struct clk corresponding to the requested possible
+ * parent clock source, or NULL.
+ */
+struct clk *clk_get_parent_by_index(struct clk *clk,
+				    unsigned int index);
+
+/**
+ * clk_get_num_parents - get number of possible parents
+ * @clk: clock source
+ *
+ * Returns the number of possible parents of this clock,
+ * which can then be enumerated using clk_get_parent_by_index().
+ */
+unsigned int clk_get_num_parents(struct clk *clk);
+
+/**
  * clk_get_sys - get a clock based upon the device name
  * @dev_id: device name
  * @con_id: connection ID
@@ -461,6 +481,17 @@ static inline struct clk *clk_get_parent(struct clk *clk)
 	return NULL;
 }
 
+static inline struct clk *clk_get_parent_by_index(struct clk *clk,
+						  unsigned int index)
+{
+	return NULL;
+}
+
+static inline unsigned int clk_get_num_parents(struct clk *clk)
+{
+	return 0;
+}
+
 #endif
 
 /* clk_prepare_enable helps cases using clk_enable in non-atomic context. */
-- 
2.5.0

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

end of thread, other threads:[~2017-02-06  6:12 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-16  6:21 [PATCH v3 1/2] clk: Add consumer APIs for discovering possible parent clocks Scott Wood
2016-06-16  6:21 ` [PATCH v3 2/2] cpufreq: qoriq: Don't look at clock implementation details Scott Wood
2016-07-07  1:30   ` Michael Turquette
2016-07-07  1:30     ` Michael Turquette
2016-07-07  4:13     ` Scott Wood
2016-07-08  2:26       ` Michael Turquette
2016-07-08  2:26         ` Michael Turquette
2016-07-08 21:06         ` Scott Wood
2016-07-20  3:02           ` Yuantian Tang
2016-07-20  3:02             ` Yuantian Tang
2017-02-02 18:11             ` Leo Li
2017-02-06  6:12               ` Y.T. Tang
2016-06-29  5:50 ` [PATCH v3 1/2] clk: Add consumer APIs for discovering possible parent clocks Yuantian Tang
2016-06-29  5:50   ` Yuantian Tang
2016-06-30  1:46   ` Rafael J. Wysocki
2016-06-30  1:47     ` Yuantian Tang
2016-06-30  1:47       ` Yuantian Tang
2016-06-30  2:24       ` Rafael J. Wysocki
2016-06-30  3:01         ` Yuantian Tang
2016-06-30  3:01           ` Yuantian Tang
2016-06-30  5:46           ` Scott Wood
2016-06-30  5:46             ` Scott Wood
2016-06-30 13:29             ` Rafael J. Wysocki
2016-07-01  6:55               ` Scott Wood
2016-07-01  6:55                 ` Scott Wood
2016-07-01 20:53                 ` Rafael J. Wysocki
2016-07-01 20:57                   ` Scott Wood
2016-07-01 20:57                     ` Scott Wood

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.