summaryrefslogtreecommitdiffstats
path: root/drivers/clk/clk.c
diff options
context:
space:
mode:
authorDinh Nguyen <dinguyen@opensource.altera.com>2015-06-05 11:26:13 -0500
committerStephen Boyd <sboyd@codeaurora.org>2015-06-05 18:10:33 -0700
commit2e61dfb3602b904966491f260f62c01b9895936a (patch)
treea0fe78e4fdb27cc74aa3920a4c996ec2a3be700e /drivers/clk/clk.c
parentd3000d0d4a2b326a3b98df53b53adcd3beead72e (diff)
downloadop-kernel-dev-2e61dfb3602b904966491f260f62c01b9895936a.zip
op-kernel-dev-2e61dfb3602b904966491f260f62c01b9895936a.tar.gz
clk: of: helper for filling parent clock array and return num of parents
Sprinkled all through the platform clock drivers are code like this to fill the clock parent array: for (i = 0; i < num_parents; ++i) parent_names[i] = of_clk_get_parent_name(np, i); The of_clk_parent_fill() will do the same as the code above, and while at it, return the number of parents as well since the logic of the function is to the walk the clock node to look for the parent. Signed-off-by: Dinh Nguyen <dinguyen@opensource.altera.com> [sboyd@codeaurora.org: Fixed kernel-doc] Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
Diffstat (limited to 'drivers/clk/clk.c')
-rw-r--r--drivers/clk/clk.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index a522dbb..ee222e2 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -3016,6 +3016,27 @@ const char *of_clk_get_parent_name(struct device_node *np, int index)
}
EXPORT_SYMBOL_GPL(of_clk_get_parent_name);
+/**
+ * of_clk_parent_fill() - Fill @parents with names of @np's parents and return
+ * number of parents
+ * @np: Device node pointer associated with clock provider
+ * @parents: pointer to char array that hold the parents' names
+ * @size: size of the @parents array
+ *
+ * Return: number of parents for the clock node.
+ */
+int of_clk_parent_fill(struct device_node *np, const char **parents,
+ unsigned int size)
+{
+ unsigned int i = 0;
+
+ while (i < size && (parents[i] = of_clk_get_parent_name(np, i)) != NULL)
+ i++;
+
+ return i;
+}
+EXPORT_SYMBOL_GPL(of_clk_parent_fill);
+
struct clock_provider {
of_clk_init_cb_t clk_init_cb;
struct device_node *np;
OpenPOWER on IntegriCloud