Merge branch 'parisc-4.9-1' of git://git.kernel.org/pub/scm/linux/kernel/git/deller...
[cascardo/linux.git] / drivers / clk / clk.c
index 820a939..0fb39fe 100644 (file)
@@ -1908,10 +1908,6 @@ int clk_set_phase(struct clk *clk, int degrees)
 
        clk_prepare_lock();
 
-       /* bail early if nothing to do */
-       if (degrees == clk->core->phase)
-               goto out;
-
        trace_clk_set_phase(clk->core, degrees);
 
        if (clk->core->ops->set_phase)
@@ -1922,7 +1918,6 @@ int clk_set_phase(struct clk *clk, int degrees)
        if (!ret)
                clk->core->phase = degrees;
 
-out:
        clk_prepare_unlock();
 
        return ret;
@@ -2449,8 +2444,16 @@ static int __clk_core_init(struct clk_core *core)
        hlist_for_each_entry_safe(orphan, tmp2, &clk_orphan_list, child_node) {
                struct clk_core *parent = __clk_init_parent(orphan);
 
-               if (parent)
-                       clk_core_reparent(orphan, parent);
+               /*
+                * we could call __clk_set_parent, but that would result in a
+                * redundant call to the .set_rate op, if it exists
+                */
+               if (parent) {
+                       __clk_set_parent_before(orphan, parent);
+                       __clk_set_parent_after(orphan, parent, NULL);
+                       __clk_recalc_accuracies(orphan);
+                       __clk_recalc_rates(orphan, 0);
+               }
        }
 
        /*
@@ -2491,7 +2494,7 @@ struct clk *__clk_create_clk(struct clk_hw *hw, const char *dev_id,
 
        /* This is to allow this function to be chained to others */
        if (IS_ERR_OR_NULL(hw))
-               return (struct clk *) hw;
+               return ERR_CAST(hw);
 
        clk = kzalloc(sizeof(*clk), GFP_KERNEL);
        if (!clk)
@@ -3166,19 +3169,14 @@ __of_clk_get_hw_from_provider(struct of_clk_provider *provider,
                              struct of_phandle_args *clkspec)
 {
        struct clk *clk;
-       struct clk_hw *hw = ERR_PTR(-EPROBE_DEFER);
 
-       if (provider->get_hw) {
-               hw = provider->get_hw(clkspec, provider->data);
-       } else if (provider->get) {
-               clk = provider->get(clkspec, provider->data);
-               if (!IS_ERR(clk))
-                       hw = __clk_get_hw(clk);
-               else
-                       hw = ERR_CAST(clk);
-       }
+       if (provider->get_hw)
+               return provider->get_hw(clkspec, provider->data);
 
-       return hw;
+       clk = provider->get(clkspec, provider->data);
+       if (IS_ERR(clk))
+               return ERR_CAST(clk);
+       return __clk_get_hw(clk);
 }
 
 struct clk *__of_clk_get_from_provider(struct of_phandle_args *clkspec,
@@ -3186,7 +3184,7 @@ struct clk *__of_clk_get_from_provider(struct of_phandle_args *clkspec,
 {
        struct of_clk_provider *provider;
        struct clk *clk = ERR_PTR(-EPROBE_DEFER);
-       struct clk_hw *hw = ERR_PTR(-EPROBE_DEFER);
+       struct clk_hw *hw;
 
        if (!clkspec)
                return ERR_PTR(-EINVAL);
@@ -3194,12 +3192,13 @@ struct clk *__of_clk_get_from_provider(struct of_phandle_args *clkspec,
        /* Check if we have such a provider in our array */
        mutex_lock(&of_clk_mutex);
        list_for_each_entry(provider, &of_clk_providers, link) {
-               if (provider->node == clkspec->np)
+               if (provider->node == clkspec->np) {
                        hw = __of_clk_get_hw_from_provider(provider, clkspec);
-               if (!IS_ERR(hw)) {
                        clk = __clk_create_clk(hw, dev_id, con_id);
+               }
 
-                       if (!IS_ERR(clk) && !__clk_get(clk)) {
+               if (!IS_ERR(clk)) {
+                       if (!__clk_get(clk)) {
                                __clk_free_clk(clk);
                                clk = ERR_PTR(-ENOENT);
                        }
@@ -3451,6 +3450,10 @@ void __init of_clk_init(const struct of_device_id *matches)
                                        &clk_provider_list, node) {
                        if (force || parent_ready(clk_provider->np)) {
 
+                               /* Don't populate platform devices */
+                               of_node_set_flag(clk_provider->np,
+                                                OF_POPULATED);
+
                                clk_provider->clk_init_cb(clk_provider->np);
                                of_clk_set_defaults(clk_provider->np, true);