clk: abstract parent cache
authorJames Hogan <james.hogan@imgtec.com>
Mon, 29 Jul 2013 11:24:58 +0000 (12:24 +0100)
committerMike Turquette <mturquette@linaro.org>
Mon, 19 Aug 2013 19:27:15 +0000 (12:27 -0700)
Abstract access to the clock parent cache by defining
clk_get_parent_by_index(clk, index). This allows access to parent
clocks from clock drivers.

Signed-off-by: James Hogan <james.hogan@imgtec.com>
Reviewed-by: Stephen Boyd <sboyd@codeaurora.org>
Cc: Mike Turquette <mturquette@linaro.org>
Cc: linux-arm-kernel@lists.infradead.org
Signed-off-by: Mike Turquette <mturquette@linaro.org>
drivers/clk/clk.c
include/linux/clk-provider.h

index 56a00db61332eee32aed15354801bf335e14368d..42c15a8ba34d30d75f01e563d53146f3cda25265 100644 (file)
@@ -559,6 +559,19 @@ struct clk *__clk_get_parent(struct clk *clk)
        return !clk ? NULL : clk->parent;
 }
 
+struct clk *clk_get_parent_by_index(struct clk *clk, u8 index)
+{
+       if (!clk || index >= clk->num_parents)
+               return NULL;
+       else if (!clk->parents)
+               return __clk_lookup(clk->parent_names[index]);
+       else if (!clk->parents[index])
+               return clk->parents[index] =
+                       __clk_lookup(clk->parent_names[index]);
+       else
+               return clk->parents[index];
+}
+
 unsigned int __clk_get_enable_count(struct clk *clk)
 {
        return !clk ? 0 : clk->enable_count;
@@ -1316,13 +1329,7 @@ static struct clk *__clk_init_parent(struct clk *clk)
                        kzalloc((sizeof(struct clk*) * clk->num_parents),
                                        GFP_KERNEL);
 
-       if (!clk->parents)
-               ret = __clk_lookup(clk->parent_names[index]);
-       else if (!clk->parents[index])
-               ret = clk->parents[index] =
-                       __clk_lookup(clk->parent_names[index]);
-       else
-               ret = clk->parents[index];
+       ret = clk_get_parent_by_index(clk, index);
 
 out:
        return ret;
index 9487b96939e850f59677b55230540b33a16b90d7..a83409285a7f7cfd34e7afb0635ee578fa199bce 100644 (file)
@@ -420,6 +420,7 @@ const char *__clk_get_name(struct clk *clk);
 struct clk_hw *__clk_get_hw(struct clk *clk);
 u8 __clk_get_num_parents(struct clk *clk);
 struct clk *__clk_get_parent(struct clk *clk);
+struct clk *clk_get_parent_by_index(struct clk *clk, u8 index);
 unsigned int __clk_get_enable_count(struct clk *clk);
 unsigned int __clk_get_prepare_count(struct clk *clk);
 unsigned long __clk_get_rate(struct clk *clk);