From patchwork Sat May 17 04:51:20 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 30350 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ob0-f198.google.com (mail-ob0-f198.google.com [209.85.214.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 3243520A25 for ; Sat, 17 May 2014 04:52:09 +0000 (UTC) Received: by mail-ob0-f198.google.com with SMTP id va2sf17288414obc.9 for ; Fri, 16 May 2014 21:52:08 -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=k+7EQt1KNMiNtxYeIxh/0xfsUKa/bYVy9F5js1YRDb4=; b=Qj9AHOYNT38Y0BP5mNXLgCzyOJ+oEI/1gKoMMcgqFtzyy8USTPSok8ngJsziqPVP1/ wTPMKBOYjxdMmEKpid9BpVfTQTnZz6idjpbbqcWWn1tebTBdc6pQ6rwrYFRIgyPR8G7w gfR580DPtkhrj7QdGAhzU5zllf8NYApPYs/qKKPbXey2fGn+hsHluf0PBxddR6NRbvzL 5CFsenUuIrNecgnlIWqGYHfRZdRqQc94SKNOC6ZIj1GPU96Q1i3/PQxMpoH6s0hEXGNQ 36VPhI43ZLTjyHzIziKshn/vK8v9Kz99FdpGkwxhQbgo2tSgO62Gquh9py5nJpDkScc8 MwJA== X-Gm-Message-State: ALoCoQmKptsengN1jicvClxlNU58u2OeZaAw0GC8it5/AgBKejPI1dVkWiYa6ZMsvVnZwnvMDdP/ X-Received: by 10.182.125.4 with SMTP id mm4mr10635215obb.49.1400302328643; Fri, 16 May 2014 21:52:08 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.28.4 with SMTP id 4ls966538qgy.39.gmail; Fri, 16 May 2014 21:52:08 -0700 (PDT) X-Received: by 10.58.126.4 with SMTP id mu4mr18072930veb.0.1400302328554; Fri, 16 May 2014 21:52:08 -0700 (PDT) Received: from mail-ve0-f179.google.com (mail-ve0-f179.google.com [209.85.128.179]) by mx.google.com with ESMTPS id sv4si2186188vdc.187.2014.05.16.21.52.08 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 16 May 2014 21:52:08 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.179 as permitted sender) client-ip=209.85.128.179; Received: by mail-ve0-f179.google.com with SMTP id oy12so4096386veb.38 for ; Fri, 16 May 2014 21:52:08 -0700 (PDT) X-Received: by 10.220.92.135 with SMTP id r7mr600165vcm.11.1400302328354; Fri, 16 May 2014 21:52:08 -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 ib8csp103905vcb; Fri, 16 May 2014 21:52:07 -0700 (PDT) X-Received: by 10.66.189.201 with SMTP id gk9mr25969678pac.25.1400302327088; Fri, 16 May 2014 21:52:07 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id wh4si5723181pbc.4.2014.05.16.21.52.06; Fri, 16 May 2014 21:52:06 -0700 (PDT) Received-SPF: none (google.com: linux-kernel-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 S1756491AbaEQEvm (ORCPT + 27 others); Sat, 17 May 2014 00:51:42 -0400 Received: from mail-pa0-f51.google.com ([209.85.220.51]:47594 "EHLO mail-pa0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756148AbaEQEvk (ORCPT ); Sat, 17 May 2014 00:51:40 -0400 Received: by mail-pa0-f51.google.com with SMTP id kq14so3421295pab.10 for ; Fri, 16 May 2014 21:51:39 -0700 (PDT) X-Received: by 10.68.196.202 with SMTP id io10mr25961444pbc.149.1400302299712; Fri, 16 May 2014 21:51:39 -0700 (PDT) Received: from localhost ([122.172.196.205]) by mx.google.com with ESMTPSA id xz7sm42598917pac.3.2014.05.16.21.51.35 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 16 May 2014 21:51:39 -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 V3 1/4] cpufreq: handle calls to ->target_index() in separate routine Date: Sat, 17 May 2014 10:21:20 +0530 Message-Id: <914cddcb07a8aa1a9ec984f436dd2bba69cfd128.1400302114.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.0.0.rc2 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@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.128.179 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. Tested-by: Stephen Warren Signed-off-by: Viresh Kumar Reviewed-by: Doug Anderson --- 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: