clk: clk_set_parent() with current parent shouldn't fail
authorStephen Boyd <sboyd@codeaurora.org>
Mon, 2 Feb 2015 22:11:25 +0000 (14:11 -0800)
committerStephen Boyd <sboyd@codeaurora.org>
Thu, 12 Mar 2015 19:18:53 +0000 (12:18 -0700)
If a driver calls clk_set_parent(clk, parent) and parent is the
current parent of clk we shouldn't fail in any case.
Unfortunately if clk is a read-only mux we return -ENOSYS
because we think we can't change the parent, except for in this
special case where we don't actually need to change the parent at
all. Return 0 in such a situation.

Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
Acked-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Michael Turquette <mturquette@linaro.org>
drivers/clk/clk.c

index 42064ce..3e10cdf 100644 (file)
@@ -2055,16 +2055,18 @@ static int clk_core_set_parent(struct clk_core *clk, struct clk_core *parent)
        if (!clk)
                return 0;
 
-       /* verify ops for for multi-parent clks */
-       if ((clk->num_parents > 1) && (!clk->ops->set_parent))
-               return -ENOSYS;
-
        /* prevent racing with updates to the clock topology */
        clk_prepare_lock();
 
        if (clk->parent == parent)
                goto out;
 
+       /* verify ops for for multi-parent clks */
+       if ((clk->num_parents > 1) && (!clk->ops->set_parent)) {
+               ret = -ENOSYS;
+               goto out;
+       }
+
        /* check that we are allowed to re-parent if the clock is in use */
        if ((clk->flags & CLK_SET_PARENT_GATE) && clk->prepare_count) {
                ret = -EBUSY;