From patchwork Thu Jun 2 14:04:59 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 69173 Delivered-To: patch@linaro.org Received: by 10.140.106.246 with SMTP id e109csp137000qgf; Thu, 2 Jun 2016 07:06:45 -0700 (PDT) X-Received: by 10.66.1.99 with SMTP id 3mr5785342pal.26.1464876405291; Thu, 02 Jun 2016 07:06:45 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id em6si4242004pac.71.2016.06.02.07.06.44; Thu, 02 Jun 2016 07:06:45 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1161230AbcFBOG3 (ORCPT + 31 others); Thu, 2 Jun 2016 10:06:29 -0400 Received: from mail-pf0-f181.google.com ([209.85.192.181]:34781 "EHLO mail-pf0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1161126AbcFBOG1 (ORCPT ); Thu, 2 Jun 2016 10:06:27 -0400 Received: by mail-pf0-f181.google.com with SMTP id 62so31821807pfd.1 for ; Thu, 02 Jun 2016 07:06:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=uCGwYeC5wb3W9f8hvrbX/2wfmaM/H322IGo39GDSuTA=; b=I+SZSPaBXEX44rv0BhKcSmIGd8ziodVgRGV9iXm/FaBvNbZK/CljjDRcG2PPCEBqQb j/lmLRRvxAZv2IK3OhAakhyc7M6o6GVzitTysq42NpTvLa7UFMmz+Rmiiu+ihyt8BTIe ckMQiDtrmFe1lvgVm1ztrRDttsMz+ATwwH94w= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=uCGwYeC5wb3W9f8hvrbX/2wfmaM/H322IGo39GDSuTA=; b=T51x4MA55INXYXyafURf3+SweVfv9Zt+fOMx9hN6v/WOlmkbc10M719v/gT/xfnq6O 3C4AMsET0+yZ8OGmXzJFC5PWfUHc7NahLtka4Ly5LqPR7/pJslW+k3qAHDasx7zCJlLN 4RUhryNrFeVBH8Vzhn3nugntUfHkNPS+YkZzXB0JtGOWqE1jZ4GGrVl4YzHX/Bi76NQ3 AVkTZ9SAZyaP2zM7Xcvhs/I8NhL9OLOgOklFCmXsq7arPQ3r2zsxK2S777JeRXj1HGpP XJLAKB4mXmQ7yteKPWIUCDarLzMfG6D2vHloJ7bistnbwebHhTf78QtWYXUMBpnNhAxo PxCA== X-Gm-Message-State: ALyK8tIjVA4uaFX0s1fbIkjjmP1cpi3wjQrdZly0MJqf/e5dMuT3MrR2bRg1d/q7n0oAsDk7 X-Received: by 10.98.61.89 with SMTP id k86mr4802893pfa.23.1464876386488; Thu, 02 Jun 2016 07:06:26 -0700 (PDT) Received: from localhost ([122.167.17.193]) by smtp.gmail.com with ESMTPSA id p1sm70686298paz.8.2016.06.02.07.06.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 02 Jun 2016 07:06:25 -0700 (PDT) From: Viresh Kumar To: Rafael Wysocki , Viresh Kumar Cc: linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH V2 5/6] cpufreq: Drop 'freq_table' argument of __target_index() Date: Thu, 2 Jun 2016 19:34:59 +0530 Message-Id: <7c6f43379512c830d28064e3b72f226059894fed.1464876229.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.7.1.410.g6faf27b In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org It is already present as part of the policy and so no need to pass it from the caller. Also, 'freq_table' is guaranteed to be valid in this function and so no need to check it. Signed-off-by: Viresh Kumar --- drivers/cpufreq/cpufreq.c | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) -- 2.7.1.410.g6faf27b diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index e68611a67bd9..30f05dd5c872 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -1852,14 +1852,17 @@ static int __target_intermediate(struct cpufreq_policy *policy, return ret; } -static int __target_index(struct cpufreq_policy *policy, - struct cpufreq_frequency_table *freq_table, int index) +static int __target_index(struct cpufreq_policy *policy, int index) { struct cpufreq_freqs freqs = {.old = policy->cur, .flags = 0}; unsigned int intermediate_freq = 0; + unsigned int newfreq = policy->freq_table[index].frequency; int retval = -EINVAL; bool notify; + if (newfreq == policy->cur) + return 0; + notify = !(cpufreq_driver->flags & CPUFREQ_ASYNC_NOTIFICATION); if (notify) { /* Handle switching to intermediate frequency */ @@ -1874,7 +1877,7 @@ static int __target_index(struct cpufreq_policy *policy, freqs.old = freqs.new; } - freqs.new = freq_table[index].frequency; + freqs.new = newfreq; pr_debug("%s: cpu: %d, oldfreq: %u, new freq: %u\n", __func__, policy->cpu, freqs.old, freqs.new); @@ -1911,7 +1914,6 @@ int __cpufreq_driver_target(struct cpufreq_policy *policy, unsigned int relation) { unsigned int old_target_freq = target_freq; - struct cpufreq_frequency_table *freq_table; int index, retval; if (cpufreq_disabled()) @@ -1941,12 +1943,6 @@ int __cpufreq_driver_target(struct cpufreq_policy *policy, if (!cpufreq_driver->target_index) return -EINVAL; - freq_table = policy->freq_table; - if (unlikely(!freq_table)) { - pr_err("%s: Unable to find freq_table\n", __func__); - return -EINVAL; - } - retval = cpufreq_frequency_table_target(policy, target_freq, relation, &index); if (unlikely(retval)) { @@ -1954,10 +1950,7 @@ int __cpufreq_driver_target(struct cpufreq_policy *policy, return retval; } - if (freq_table[index].frequency == policy->cur) - return 0; - - return __target_index(policy, freq_table, index); + return __target_index(policy, index); } EXPORT_SYMBOL_GPL(__cpufreq_driver_target);