[PATCH] clk: skip unnecessary set_phase if nothing to do

From: Shawn Lin
Date: Thu Feb 25 2016 - 20:32:08 EST


Let's compare the degrees from clk_set_rate with
clk->core->phase. If the requested drgrees is already
there, skip the following steps.

Signed-off-by: Shawn Lin <shawn.lin@xxxxxxxxxxxxxx>
---

drivers/clk/clk.c | 5 +++++
1 file changed, 5 insertions(+)

diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index b4db67a..549fdb8 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -1902,6 +1902,10 @@ 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)
@@ -1912,6 +1916,7 @@ int clk_set_phase(struct clk *clk, int degrees)
if (!ret)
clk->core->phase = degrees;

+out:
clk_prepare_unlock();

return ret;
--
2.3.7