msm: clock: Return early if same rate used in clk_set_rate()
Now that the rate field is cached inside struct clk we can move
the check for 'rate == current rate' to the toplevel clock.c
code. This way each hardware specific driver doesn't have to
duplicate code and check for this condition in their
clk_set_rate() ops.
Change-Id: I5350ec61683713f7f9dd5c278b44a7c27463df1a
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
diff --git a/arch/arm/mach-msm/clock.c b/arch/arm/mach-msm/clock.c
index fb5b580..8a1c6eb 100644
--- a/arch/arm/mach-msm/clock.c
+++ b/arch/arm/mach-msm/clock.c
@@ -320,7 +320,7 @@
int clk_set_rate(struct clk *clk, unsigned long rate)
{
unsigned long start_rate, flags;
- int rc;
+ int rc = 0;
if (IS_ERR_OR_NULL(clk))
return -EINVAL;
@@ -329,6 +329,11 @@
return -ENOSYS;
spin_lock_irqsave(&clk->lock, flags);
+
+ /* Return early if the rate isn't going to change */
+ if (clk->rate == rate)
+ goto out;
+
trace_clock_set_rate(clk->dbg_name, rate, smp_processor_id());
if (clk->count) {
start_rate = clk->rate;
@@ -347,7 +352,7 @@
if (!rc)
clk->rate = rate;
-
+out:
spin_unlock_irqrestore(&clk->lock, flags);
return rc;