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-local.c b/arch/arm/mach-msm/clock-local.c
index 4f365fa..02e103d 100644
--- a/arch/arm/mach-msm/clock-local.c
+++ b/arch/arm/mach-msm/clock-local.c
@@ -464,10 +464,7 @@
if (nf->freq_hz == FREQ_END)
return -EINVAL;
- /* Check if frequency is actually changed. */
cf = clk->current_freq;
- if (nf == cf)
- return 0;
if (clk->enabled) {
/* Enable source clock dependency for the new freq. */
@@ -881,9 +878,6 @@
if (rate > clk->max_div)
return -EINVAL;
- /* Check if frequency is actually changed. */
- if (rate == clk->cur_div)
- return 0;
spin_lock(&local_clock_reg_lock);
reg_val = readl_relaxed(clk->ns_reg);
diff --git a/arch/arm/mach-msm/clock-local2.c b/arch/arm/mach-msm/clock-local2.c
index cf45e63..c84cfb8 100644
--- a/arch/arm/mach-msm/clock-local2.c
+++ b/arch/arm/mach-msm/clock-local2.c
@@ -166,10 +166,7 @@
if (nf->freq_hz == FREQ_END)
return -EINVAL;
- /* Check if frequency is actually changed. */
cf = rcg->current_freq;
- if (nf == cf)
- return 0;
if (rcg->c.count) {
/* TODO: Modify to use the prepare API */
diff --git a/arch/arm/mach-msm/clock-rpm.c b/arch/arm/mach-msm/clock-rpm.c
index ae87bb7..4539828 100644
--- a/arch/arm/mach-msm/clock-rpm.c
+++ b/arch/arm/mach-msm/clock-rpm.c
@@ -116,10 +116,6 @@
spin_lock_irqsave(&rpm_clock_lock, flags);
- /* Ignore duplicate requests. */
- if (r->last_set_khz == this_khz)
- goto out;
-
/* Active-only clocks don't care what the rate is during sleep. So,
* they vote for zero. */
if (r->active_only)
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;