From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754218AbcBGPYM (ORCPT ); Sun, 7 Feb 2016 10:24:12 -0500 Received: from v094114.home.net.pl ([79.96.170.134]:43340 "HELO v094114.home.net.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1753901AbcBGPYG (ORCPT ); Sun, 7 Feb 2016 10:24:06 -0500 From: "Rafael J. Wysocki" To: Linux PM list Cc: Linux Kernel Mailing List , Viresh Kumar , Srinivas Pandruvada , Juri Lelli , Steve Muckle , Saravana Kannan Subject: [PATCH 1/3] cpufreq: governor: Simplify cpufreq_governor_limits() Date: Sun, 07 Feb 2016 16:23:49 +0100 Message-ID: <1465939.LaiBibfCQO@vostro.rjw.lan> User-Agent: KMail/4.11.5 (Linux/4.5.0-rc1+; KDE/4.11.5; x86_64; ; ) In-Reply-To: <2998470.K7oslgfuja@vostro.rjw.lan> References: <3705929.bslqXH980s@vostro.rjw.lan> <9008098.QDD8C89zDx@vostro.rjw.lan> <2998470.K7oslgfuja@vostro.rjw.lan> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="utf-8" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Rafael J. Wysocki 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 --- drivers/cpufreq/cpufreq_governor.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) 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; }