From patchwork Fri Sep 13 12:59:10 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 20058 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vb0-f71.google.com (mail-vb0-f71.google.com [209.85.212.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id E2E1A202E6 for ; Fri, 13 Sep 2013 13:03:31 +0000 (UTC) Received: by mail-vb0-f71.google.com with SMTP id g17sf1183261vbg.10 for ; Fri, 13 Sep 2013 06:03:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:in-reply-to:references :x-original-sender:x-original-authentication-results:precedence :mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=a4XGnR8JgCf7H69MfjdhBt7lcV0nOd3EQkhX5iMt+go=; b=aza0R+K/afIqReJw/SzYSAH0n3UnUHHg3Z4ncGG6oFVvgfVFLP+yK5LahRQn416emC MJVgjQpjNlYyXTZLMpJ/UUxXzd9OqRMeskFQh/ZaPHtKLp/p1Ksll7mOFySQyJ4CzTwa r8+MaqHZMzx7nWoJSHAXP8pt2qax1m9B0nJwAOwE7pD+ouxpPGqJKVKkTgpLtiEFp/fi OVOkq+FoPUvxJ1L3YiDz5wQ2MUDNZoT0JGfjIt34Um0psVGbogcxYra7kdE+LIdqCSmR vkWYC501VtWbrVRZLUNvbYvH7CoBss6cEAJoannCbfczCiL8snluzycPQlUWECcLWxYu +WZQ== X-Gm-Message-State: ALoCoQkjYV3IpEMEVymhctIQ9fWdDpNlQLt0YZ/cN5eqku+hAG7Y5IP39tTM92UzJyFBOf5UTBGn X-Received: by 10.236.93.45 with SMTP id k33mr5135329yhf.19.1379077411492; Fri, 13 Sep 2013 06:03:31 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.35.43 with SMTP id e11ls1140659qej.54.gmail; Fri, 13 Sep 2013 06:03:31 -0700 (PDT) X-Received: by 10.220.145.75 with SMTP id c11mr233441vcv.30.1379077411281; Fri, 13 Sep 2013 06:03:31 -0700 (PDT) Received: from mail-vb0-f52.google.com (mail-vb0-f52.google.com [209.85.212.52]) by mx.google.com with ESMTPS id ch11si3095305ved.63.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 13 Sep 2013 06:03:31 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.212.52 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.212.52; Received: by mail-vb0-f52.google.com with SMTP id f12so857957vbg.39 for ; Fri, 13 Sep 2013 06:03:31 -0700 (PDT) X-Received: by 10.52.34.109 with SMTP id y13mr10233841vdi.8.1379077411185; Fri, 13 Sep 2013 06:03:31 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp79400vcz; Fri, 13 Sep 2013 06:03:29 -0700 (PDT) X-Received: by 10.66.154.1 with SMTP id vk1mr15309326pab.85.1379077409237; Fri, 13 Sep 2013 06:03:29 -0700 (PDT) Received: from mail-pa0-f50.google.com (mail-pa0-f50.google.com [209.85.220.50]) by mx.google.com with ESMTPS id dl5si1948609pbd.146.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 13 Sep 2013 06:03:29 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.50 is neither permitted nor denied by best guess record for domain of viresh.kumar@linaro.org) client-ip=209.85.220.50; Received: by mail-pa0-f50.google.com with SMTP id fb10so2524406pad.9 for ; Fri, 13 Sep 2013 06:03:28 -0700 (PDT) X-Received: by 10.68.252.233 with SMTP id zv9mr13238655pbc.69.1379077408769; Fri, 13 Sep 2013 06:03:28 -0700 (PDT) Received: from localhost ([122.167.78.148]) by mx.google.com with ESMTPSA id sb9sm11665248pbb.0.1969.12.31.16.00.00 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 13 Sep 2013 06:03:28 -0700 (PDT) From: Viresh Kumar To: rjw@sisk.pl Cc: linaro-kernel@lists.linaro.org, patches@linaro.org, cpufreq@vger.kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Viresh Kumar Subject: [PATCH 004/228] cpufreq: Optimize cpufreq_frequency_table_verify() Date: Fri, 13 Sep 2013 18:29:10 +0530 Message-Id: <7237b6f0cb157cf7989be74c4f1a10750df28b7c.1379063063.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 1.7.12.rc2.18.g61b472e In-Reply-To: References: In-Reply-To: References: X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: viresh.kumar@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.212.52 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , cpufreq_frequency_table_verify() is a bit rewritten here to make it more logical and optimal. - merge multiple lines for variable declarations together. - quit early if any frequency between min/max is found. - don't call cpufreq_verify_within_limits() in case any valid freq is found as it is of no use. - count renamed as found and made a boolean. Signed-off-by: Viresh Kumar --- drivers/cpufreq/freq_table.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/drivers/cpufreq/freq_table.c b/drivers/cpufreq/freq_table.c index f111454a..53a2f1a 100644 --- a/drivers/cpufreq/freq_table.c +++ b/drivers/cpufreq/freq_table.c @@ -54,9 +54,8 @@ EXPORT_SYMBOL_GPL(cpufreq_frequency_table_cpuinfo); int cpufreq_frequency_table_verify(struct cpufreq_policy *policy, struct cpufreq_frequency_table *table) { - unsigned int next_larger = ~0; - unsigned int i; - unsigned int count = 0; + unsigned int next_larger = ~0, freq, i = 0; + bool found = false; pr_debug("request for verification of policy (%u - %u kHz) for cpu %u\n", policy->min, policy->max, policy->cpu); @@ -64,21 +63,23 @@ int cpufreq_frequency_table_verify(struct cpufreq_policy *policy, cpufreq_verify_within_limits(policy, policy->cpuinfo.min_freq, policy->cpuinfo.max_freq); - for (i = 0; (table[i].frequency != CPUFREQ_TABLE_END); i++) { - unsigned int freq = table[i].frequency; + for (; freq = table[i].frequency, freq != CPUFREQ_TABLE_END; i++) { if (freq == CPUFREQ_ENTRY_INVALID) continue; - if ((freq >= policy->min) && (freq <= policy->max)) - count++; - else if ((next_larger > freq) && (freq > policy->max)) + if ((freq >= policy->min) && (freq <= policy->max)) { + found = true; + break; + } + + if ((next_larger > freq) && (freq > policy->max)) next_larger = freq; } - if (!count) + if (!found) { policy->max = next_larger; - - cpufreq_verify_within_limits(policy, policy->cpuinfo.min_freq, - policy->cpuinfo.max_freq); + cpufreq_verify_within_limits(policy, policy->cpuinfo.min_freq, + policy->cpuinfo.max_freq); + } pr_debug("verification lead to (%u - %u kHz) for cpu %u\n", policy->min, policy->max, policy->cpu);