Merge branch 'v4.3-topic/clk-samsung' of git://git.kernel.org/pub/scm/linux/kernel...
[firefly-linux-kernel-4.4.55.git] / drivers / clk / st / clk-flexgen.c
index bf12a25eb3a22aab048f04d5280195d21bd7dd01..ec20a2c6f9f3219f17f7b3c89f266bf566b32a0b 100644 (file)
@@ -5,6 +5,7 @@
  * Author:  Maxime Coquelin <maxime.coquelin@st.com> for ST-Microelectronics.
  * License terms:  GNU General Public License (GPL), version 2  */
 
+#include <linux/clk.h>
 #include <linux/clk-provider.h>
 #include <linux/module.h>
 #include <linux/slab.h>
@@ -116,7 +117,7 @@ static long flexgen_round_rate(struct clk_hw *hw, unsigned long rate,
        return *prate / div;
 }
 
-unsigned long flexgen_recalc_rate(struct clk_hw *hw,
+static unsigned long flexgen_recalc_rate(struct clk_hw *hw,
                unsigned long parent_rate)
 {
        struct flexgen *flexgen = to_flexgen(hw);
@@ -174,7 +175,7 @@ static const struct clk_ops flexgen_ops = {
        .set_rate = flexgen_set_rate,
 };
 
-struct clk *clk_register_flexgen(const char *name,
+static struct clk *clk_register_flexgen(const char *name,
                                const char **parent_names, u8 num_parents,
                                void __iomem *reg, spinlock_t *lock, u32 idx,
                                unsigned long flexgen_flags) {
@@ -190,7 +191,7 @@ struct clk *clk_register_flexgen(const char *name,
 
        init.name = name;
        init.ops = &flexgen_ops;
-       init.flags = CLK_IS_BASIC | flexgen_flags;
+       init.flags = CLK_IS_BASIC | CLK_GET_RATE_NOCACHE | flexgen_flags;
        init.parent_names = parent_names;
        init.num_parents = num_parents;
 
@@ -243,9 +244,9 @@ static const char ** __init flexgen_get_parents(struct device_node *np,
                                                       int *num_parents)
 {
        const char **parents;
-       int nparents, i;
+       int nparents;
 
-       nparents = of_count_phandle_with_args(np, "clocks", "#clock-cells");
+       nparents = of_clk_get_parent_count(np);
        if (WARN_ON(nparents <= 0))
                return NULL;
 
@@ -253,14 +254,12 @@ static const char ** __init flexgen_get_parents(struct device_node *np,
        if (!parents)
                return NULL;
 
-       for (i = 0; i < nparents; i++)
-               parents[i] = of_clk_get_parent_name(np, i);
+       *num_parents = of_clk_parent_fill(np, parents, nparents);
 
-       *num_parents = nparents;
        return parents;
 }
 
-void __init st_of_flexgen_setup(struct device_node *np)
+static void __init st_of_flexgen_setup(struct device_node *np)
 {
        struct device_node *pnode;
        void __iomem *reg;
@@ -303,6 +302,8 @@ void __init st_of_flexgen_setup(struct device_node *np)
        if (!rlock)
                goto err;
 
+       spin_lock_init(rlock);
+
        for (i = 0; i < clk_data->clk_num; i++) {
                struct clk *clk;
                const char *clk_name;