diff mbox

[1/3] cpufreq: governor: Simplify cpufreq_governor_limits()

Message ID 1465939.LaiBibfCQO@vostro.rjw.lan (mailing list archive)
State Accepted, archived
Delegated to: Rafael Wysocki
Headers show

Commit Message

Rafael J. Wysocki Feb. 7, 2016, 3:23 p.m. UTC
From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

Use the observation that cpufreq_governor_limits() doesn't have to
get to the policy object it wants to manipulate by walking the
reference chain cdbs->policy_dbs->policy, as the final pointer is
actually equal to its argument, and make it access the policy
object directy via its argument.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
 drivers/cpufreq/cpufreq_governor.c |   17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)


--
To unsubscribe from this list: send the line "unsubscribe linux-pm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Viresh Kumar Feb. 7, 2016, 3:40 p.m. UTC | #1
On 07-02-16, 16:23, Rafael J. Wysocki wrote:
> From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> 
> Use the observation that cpufreq_governor_limits() doesn't have to
> get to the policy object it wants to manipulate by walking the
> reference chain cdbs->policy_dbs->policy, as the final pointer is
> actually equal to its argument, and make it access the policy
> object directy via its argument.
> 
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> ---
>  drivers/cpufreq/cpufreq_governor.c |   17 ++++++++---------
>  1 file changed, 8 insertions(+), 9 deletions(-)

Why the hell did we write it that way earlier ? :)

Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Rafael J. Wysocki Feb. 8, 2016, 12:59 a.m. UTC | #2
On Sunday, February 07, 2016 09:10:24 PM Viresh Kumar wrote:
> On 07-02-16, 16:23, Rafael J. Wysocki wrote:
> > From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> > 
> > Use the observation that cpufreq_governor_limits() doesn't have to
> > get to the policy object it wants to manipulate by walking the
> > reference chain cdbs->policy_dbs->policy, as the final pointer is
> > actually equal to its argument, and make it access the policy
> > object directy via its argument.
> > 
> > Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> > ---
> >  drivers/cpufreq/cpufreq_governor.c |   17 ++++++++---------
> >  1 file changed, 8 insertions(+), 9 deletions(-)
> 
> Why the hell did we write it that way earlier ? :)

Honestly, I have no idea.

> Acked-by: Viresh Kumar <viresh.kumar@linaro.org>

Thanks!

--
To unsubscribe from this list: send the line "unsubscribe linux-pm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

Index: linux-pm/drivers/cpufreq/cpufreq_governor.c
===================================================================
--- linux-pm.orig/drivers/cpufreq/cpufreq_governor.c
+++ linux-pm/drivers/cpufreq/cpufreq_governor.c
@@ -518,20 +518,19 @@  static int cpufreq_governor_limits(struc
 {
 	struct dbs_governor *gov = dbs_governor_of(policy);
 	struct cpu_dbs_info *cdbs = gov->get_cpu_cdbs(policy->cpu);
+	struct policy_dbs_info *policy_dbs = cdbs->policy_dbs;
 
 	/* State should be equivalent to START */
-	if (!cdbs->policy_dbs || !cdbs->policy_dbs->policy)
+	if (!policy_dbs || !policy_dbs->policy)
 		return -EBUSY;
 
-	mutex_lock(&cdbs->policy_dbs->timer_mutex);
-	if (policy->max < cdbs->policy_dbs->policy->cur)
-		__cpufreq_driver_target(cdbs->policy_dbs->policy, policy->max,
-					CPUFREQ_RELATION_H);
-	else if (policy->min > cdbs->policy_dbs->policy->cur)
-		__cpufreq_driver_target(cdbs->policy_dbs->policy, policy->min,
-					CPUFREQ_RELATION_L);
+	mutex_lock(&policy_dbs->timer_mutex);
+	if (policy->max < policy->cur)
+		__cpufreq_driver_target(policy, policy->max, CPUFREQ_RELATION_H);
+	else if (policy->min > policy->cur)
+		__cpufreq_driver_target(policy, policy->min, CPUFREQ_RELATION_L);
 	dbs_check_cpu(policy);
-	mutex_unlock(&cdbs->policy_dbs->timer_mutex);
+	mutex_unlock(&policy_dbs->timer_mutex);
 
 	return 0;
 }