From patchwork Fri Jun 3 05:28:50 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 69222 Delivered-To: patch@linaro.org Received: by 10.140.106.246 with SMTP id e109csp90809qgf; Thu, 2 Jun 2016 22:29:48 -0700 (PDT) X-Received: by 10.98.157.89 with SMTP id i86mr3521385pfd.121.1464931786116; Thu, 02 Jun 2016 22:29:46 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r82si5213253pfa.197.2016.06.02.22.29.45; Thu, 02 Jun 2016 22:29:46 -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 S1752049AbcFCF3e (ORCPT + 31 others); Fri, 3 Jun 2016 01:29:34 -0400 Received: from mail-pa0-f44.google.com ([209.85.220.44]:36579 "EHLO mail-pa0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751935AbcFCF3W (ORCPT ); Fri, 3 Jun 2016 01:29:22 -0400 Received: by mail-pa0-f44.google.com with SMTP id te7so7993785pab.3 for ; Thu, 02 Jun 2016 22:29:22 -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=eut6MXI7hFtQFyIFJ8KwcWbUlpvnd4ldzI2trpPIfJQ91AUR7X/sm1QJk99WK7RBIq f4Jmzvny51YIpJincs4rP1uNl2ZjNblkfDJV3wd1iIThefZe/H5Hu5ro81zdKilwiGM2 WBY9xcC8wG1PSVThtRuNZan2I1STTIGA0Jcyc= 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=K7yGNRbLpRuvxRTXlTAocTJC+xPLb3Jsuxv0oMG/lKWaS+PXnrHMM+mAYR4FbI0GYX 8fHwkhewQygWuyjesmAoYyphP5lxvZ1U7FE66AHcgG1xbRruvpV5Nf7Kk5L9XFO3Faf9 YwTliSmF7b8nH8SdOuSsLCRgxpjx6D5qH53yaQZc01/nRzuv/L4wV/5nWVwmMdhsQtH6 3IwawTk4jx2Rx5/Khz8RydfIZ4Zx12/UF9oI/P/a1pU7VC5eXiDV0aTuOj+laILCyHbC wBTcAw3zEl6M0G6jtmpzbjQ6hzx82Nyycga6WtJsoCFdqxf69vc3rRvKNnIdatqztzsq WzAQ== X-Gm-Message-State: ALyK8tJAG1kyuFbNV2qQZ3egYE8yrNEf2q5k1AEbFdpYsMXiZaGZ7kpLDYsDZKDgKXe/qIIP X-Received: by 10.66.185.68 with SMTP id fa4mr2706696pac.41.1464931761526; Thu, 02 Jun 2016 22:29:21 -0700 (PDT) Received: from localhost ([122.167.17.193]) by smtp.gmail.com with ESMTPSA id g11sm4671446pfd.89.2016.06.02.22.29.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 02 Jun 2016 22:29:20 -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 V3 6/8] cpufreq: Drop 'freq_table' argument of __target_index() Date: Fri, 3 Jun 2016 10:58:50 +0530 Message-Id: <8a338cbe37e80bd569d41136e9ba78c927e4429d.1464931080.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);