Skip to content

Commit

Permalink
clk: Missing set_phase op is an error
Browse files Browse the repository at this point in the history
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.

Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
Signed-off-by: Michael Turquette <mturquette@linaro.org>
  • Loading branch information
Stephen Boyd committed Mar 12, 2015
1 parent 6b54783 commit 08b9575
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions drivers/clk/clk.c
Original file line number Diff line number Diff line change
Expand Up @@ -2123,10 +2123,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;
Expand All @@ -2135,18 +2135,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);
Expand Down

0 comments on commit 08b9575

Please sign in to comment.