From patchwork Fri May 16 09:03:34 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 30318 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-oa0-f70.google.com (mail-oa0-f70.google.com [209.85.219.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 17E10202E4 for ; Fri, 16 May 2014 09:04:08 +0000 (UTC) Received: by mail-oa0-f70.google.com with SMTP id i4sf11419791oah.5 for ; Fri, 16 May 2014 02:04:07 -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 :sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=hPHANEmHu3nrV2jIEeKYYojrH6IV+N9huzv4Xl+WT3A=; b=OYhuEJxPcz6zQFEC//tjP1lwVXoTaoGTNWCmykQqDvnZ7r4yQPJUsnfcre7QyvxiWu jQc3L/VF+98lrDi5JPyiHnbJG9YS4I1HEj9nFwxeD+wIx5vK4d2W60udDHQJTU6E3xuZ jNq5FFF8IP0YO6PhjHgLycB0P3x0lqSEmf2wkGojNbarzsQW+zoY4QYVgiS88cY5X2fE rykRyrFJ1juevQq9tixsi8dxZH3rfhHdCZ8pWUVOFEtgj68625evBLGEDfx3kyCZVd+w 9we1nFEo4fDyxH0da2/Pe1/gnk/T/15kInvEwK3RgSrK/J+V6Prb+6jp5d4xzKCG6Id6 GOpQ== X-Gm-Message-State: ALoCoQlsCtEwIzqx54u5Wv1kmkD2ae+V0iE+3Gs0LLp3jSVIG76h7DV74STljwWvt1ERgAEG1+J+ X-Received: by 10.42.30.71 with SMTP id u7mr6432387icc.15.1400231047687; Fri, 16 May 2014 02:04:07 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.87.141 with SMTP id r13ls663156qgd.98.gmail; Fri, 16 May 2014 02:04:07 -0700 (PDT) X-Received: by 10.221.69.68 with SMTP id yb4mr70629vcb.49.1400231047548; Fri, 16 May 2014 02:04:07 -0700 (PDT) Received: from mail-vc0-f172.google.com (mail-vc0-f172.google.com [209.85.220.172]) by mx.google.com with ESMTPS id d12si1436522vco.83.2014.05.16.02.04.07 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 16 May 2014 02:04:07 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.172 as permitted sender) client-ip=209.85.220.172; Received: by mail-vc0-f172.google.com with SMTP id hr9so5814103vcb.31 for ; Fri, 16 May 2014 02:04:07 -0700 (PDT) X-Received: by 10.220.161.8 with SMTP id p8mr13108964vcx.4.1400231047444; Fri, 16 May 2014 02:04:07 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.221.72 with SMTP id ib8csp35397vcb; Fri, 16 May 2014 02:04:06 -0700 (PDT) X-Received: by 10.66.236.163 with SMTP id uv3mr19196653pac.18.1400231045509; Fri, 16 May 2014 02:04:05 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id xe4si8268587pab.28.2014.05.16.02.04.04; Fri, 16 May 2014 02:04:05 -0700 (PDT) Received-SPF: none (google.com: linux-pm-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932185AbaEPJEA (ORCPT + 12 others); Fri, 16 May 2014 05:04:00 -0400 Received: from mail-pa0-f52.google.com ([209.85.220.52]:60040 "EHLO mail-pa0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756494AbaEPJD6 (ORCPT ); Fri, 16 May 2014 05:03:58 -0400 Received: by mail-pa0-f52.google.com with SMTP id fa1so2308263pad.39 for ; Fri, 16 May 2014 02:03:57 -0700 (PDT) X-Received: by 10.68.219.162 with SMTP id pp2mr19345958pbc.47.1400231037676; Fri, 16 May 2014 02:03:57 -0700 (PDT) Received: from localhost ([122.167.73.49]) by mx.google.com with ESMTPSA id yv5sm13385259pbb.49.2014.05.16.02.03.53 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 16 May 2014 02:03:57 -0700 (PDT) From: Viresh Kumar To: rjw@rjwysocki.net Cc: linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, arvind.chauhan@arm.com, swarren@nvidia.com, nicolas.pitre@linaro.org, swarren@wwwdotorg.org, dianders@chromium.org, linux@arm.linux.org.uk, thomas.abraham@linaro.org, pdeschrijver@nvidia.com, Viresh Kumar Subject: [PATCH V2 1/3] cpufreq: handle calls to ->target_index() in separate routine Date: Fri, 16 May 2014 14:33:34 +0530 Message-Id: <6d2abaff073c0106f2d5d386f55d2ab57d8f3576.1400230695.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.0.0.rc2 In-Reply-To: References: In-Reply-To: References: Sender: linux-pm-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: viresh.kumar@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.172 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Handling calls to ->target_index() has got complex over time and might become more complex. So, its better to take target_index() bits out in another routine __target_index() for better code readability. Shouldn't have any functional impact. Signed-off-by: Viresh Kumar --- drivers/cpufreq/cpufreq.c | 56 ++++++++++++++++++++++++++++------------------- 1 file changed, 33 insertions(+), 23 deletions(-) diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index a05c921..9bf12a2 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -1816,12 +1816,43 @@ EXPORT_SYMBOL(cpufreq_unregister_notifier); * GOVERNORS * *********************************************************************/ +static int __target_index(struct cpufreq_policy *policy, + struct cpufreq_frequency_table *freq_table, int index) +{ + struct cpufreq_freqs freqs; + int retval = -EINVAL; + bool notify; + + notify = !(cpufreq_driver->flags & CPUFREQ_ASYNC_NOTIFICATION); + + if (notify) { + freqs.old = policy->cur; + freqs.new = freq_table[index].frequency; + freqs.flags = 0; + + pr_debug("%s: cpu: %d, oldfreq: %u, new freq: %u\n", + __func__, policy->cpu, freqs.old, freqs.new); + + cpufreq_freq_transition_begin(policy, &freqs); + } + + retval = cpufreq_driver->target_index(policy, index); + if (retval) + pr_err("%s: Failed to change cpu frequency: %d\n", + __func__, retval); + + if (notify) + cpufreq_freq_transition_end(policy, &freqs, retval); + + return retval; +} + int __cpufreq_driver_target(struct cpufreq_policy *policy, unsigned int target_freq, unsigned int relation) { - int retval = -EINVAL; unsigned int old_target_freq = target_freq; + int retval = -EINVAL; if (cpufreq_disabled()) return -ENODEV; @@ -1848,8 +1879,6 @@ int __cpufreq_driver_target(struct cpufreq_policy *policy, retval = cpufreq_driver->target(policy, target_freq, relation); else if (cpufreq_driver->target_index) { struct cpufreq_frequency_table *freq_table; - struct cpufreq_freqs freqs; - bool notify; int index; freq_table = cpufreq_frequency_get_table(policy->cpu); @@ -1870,26 +1899,7 @@ int __cpufreq_driver_target(struct cpufreq_policy *policy, goto out; } - notify = !(cpufreq_driver->flags & CPUFREQ_ASYNC_NOTIFICATION); - - if (notify) { - freqs.old = policy->cur; - freqs.new = freq_table[index].frequency; - freqs.flags = 0; - - pr_debug("%s: cpu: %d, oldfreq: %u, new freq: %u\n", - __func__, policy->cpu, freqs.old, freqs.new); - - cpufreq_freq_transition_begin(policy, &freqs); - } - - retval = cpufreq_driver->target_index(policy, index); - if (retval) - pr_err("%s: Failed to change cpu frequency: %d\n", - __func__, retval); - - if (notify) - cpufreq_freq_transition_end(policy, &freqs, retval); + retval = __target_index(policy, freq_table, index); } out: