Skip to contentSkip to conversation

clk: Missing set_phase op is an error

PATCH Applied Stephen Boyd 2 participants 2 messages Feb 2, 2015 – Feb 25, 2015 Common clk

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 clk: Missing set_phase op is an error

If a clock's clk_ops doesn't have the set_phase op set we should return an error from clk_set_phase(). This way clock consumers know that when they tried to set a phase it didn't work, as opposed to the current behavior where the return value is 0 meaning success.

---
 drivers/clk/clk.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)
drivers/clk/clk.c +4 -8
index a29daf9edea4..b82714a84f5e 100644
@@ -2069,10 +2069,10 @@ EXPORT_SYMBOL_GPL(clk_set_parent);
  */
 int clk_set_phase(struct clk *clk, int degrees)
 {
-	int ret = 0;
+	int ret = -EINVAL;
 
 	if (!clk)
-		goto out;
+		return 0;
 
 	/* sanity check degrees */
 	degrees %= 360;
@@ -2081,18 +2081,14 @@ int clk_set_phase(struct clk *clk, int degrees)
 
 	clk_prepare_lock();
 
-	if (!clk->core->ops->set_phase)
-		goto out_unlock;
-
-	ret = clk->core->ops->set_phase(clk->core->hw, degrees);
+	if (clk->core->ops->set_phase)
+		ret = clk->core->ops->set_phase(clk->core->hw, degrees);
 
 	if (!ret)
 		clk->core->phase = degrees;
 
-out_unlock:
 	clk_prepare_unlock();
 
-out:
 	return ret;
 }
 EXPORT_SYMBOL_GPL(clk_set_phase);
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
#1 lore raw

Quoting Stephen Boyd (2015-02-02 14:09:43)

Quoted 7 lines

If a clock's clk_ops doesn't have the set_phase op set we should return an error from clk_set_phase(). This way clock consumers know that when they tried to set a phase it didn't work, as opposed to the current behavior where the return value is 0 meaning success.

Applied to clk-next.

Thanks,
Mike

Quoted 46 lines
---
 drivers/clk/clk.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)
drivers/clk/clk.c +4 -8
index a29daf9edea4..b82714a84f5e 100644
@@ -2069,10 +2069,10 @@ EXPORT_SYMBOL_GPL(clk_set_parent);
  */
 int clk_set_phase(struct clk *clk, int degrees)
 {
-       int ret = 0;
+       int ret = -EINVAL;
 
        if (!clk)
-               goto out;
+               return 0;
 
        /* sanity check degrees */
        degrees %= 360;
@@ -2081,18 +2081,14 @@ int clk_set_phase(struct clk *clk, int degrees)
 
        clk_prepare_lock();
 
-       if (!clk->core->ops->set_phase)
-               goto out_unlock;
-
-       ret = clk->core->ops->set_phase(clk->core->hw, degrees);
+       if (clk->core->ops->set_phase)
+               ret = clk->core->ops->set_phase(clk->core->hw, degrees);
 
        if (!ret)
                clk->core->phase = degrees;
 
-out_unlock:
        clk_prepare_unlock();
 
-out:
        return ret;
 }
 EXPORT_SYMBOL_GPL(clk_set_phase);
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project