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: 9150029 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id ABE226074E for ; Thu, 2 Jun 2016 14:07:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9DA1220120 for ; Thu, 2 Jun 2016 14:07:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9273A28294; Thu, 2 Jun 2016 14:07:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_WEB, T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1107320120 for ; Thu, 2 Jun 2016 14:07:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1161212AbcFBOG2 (ORCPT ); Thu, 2 Jun 2016 10:06:28 -0400 Received: from mail-pf0-f169.google.com ([209.85.192.169]:35933 "EHLO mail-pf0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1161211AbcFBOG1 (ORCPT ); Thu, 2 Jun 2016 10:06:27 -0400 Received: by mail-pf0-f169.google.com with SMTP id f144so31821403pfa.3 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=OOAbPFuxZB9MsLZo29TzE5aTldeu4jqikVizwaHxGXZbcfCEetVB5drzeZHgtU+uDx 4BhhtcBVaEHqNSooffKcQT39m2ACFW4LWvly2m+97h7f7PHeqoKugGI5AOvzWvxxlwVl GzsYCR/LcpK8nsWQko6JqaYV7STP733qa+8I1nszgRd0++R+2vhyqhTz1ZYO4mz6s7kQ xVJ/K+Qd7pNgtH3gy24nOH2BEoirrVOwMBDsPBflmmlqWDvhPwuopcjdFj4d1NdF1Ra5 QQLoMkTjc9B/djPRxsoKWLViJC5R/HAG0nvS9uocRBw4dauRmlHJj4Dn03otrASbvdCv TITw== X-Gm-Message-State: ALyK8tIo2+OO3jGc26tMUiHPvLbRnf8A+yt61y+VRS0yqU2Bs2mzKvDsm1uH3B7k3RIKWQ38 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-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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(-) 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);