From patchwork Wed May 21 08:59:29 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 30517 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pa0-f69.google.com (mail-pa0-f69.google.com [209.85.220.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id E097720671 for ; Wed, 21 May 2014 09:04:57 +0000 (UTC) Received: by mail-pa0-f69.google.com with SMTP id ey11sf5154723pad.8 for ; Wed, 21 May 2014 02:04:56 -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=0Ej4qk96BXlT6r9YsjoCbUMvtgFNiOtNJLVcbgzYo2I=; b=BxNTo9Jv3C0CU/a1sGWDEOxJWPTkZk9mAbyJK3eqo6uoKJPBfmFhQBw/jctdfnHg/4 sj7anHKf8yvc4dBwTsNwX/l2tJalONHvCHFtuVSkA3tZ0n/WuvxnuwpSEpQGNga2bXIc WOTRBBaSAB0rGFOh5snngXs7wiCERzZR+2ZBorCd89n6wSyZQPDlnARBI4onsiF+o7Cc cemauxwhGlrplTVfV7VS8obO8EFwGe9qFiILbh+PbP9HTazehNJE7YFxDA0JFH/jLBzY mN+X+wSG6VQrmSc7PxW6jYBBnkVPHbIDvUvXb2cmGNhZhJ8SlLtRlZ6Z0fvXLjE3AcRm 2gtg== X-Gm-Message-State: ALoCoQnhzJ4cwVW2oG7xz5oD3hKtrSqQHBlYZpvxs/bUqPoch9fFIgB4F5aHgbEQaG2UuPE72eQk X-Received: by 10.66.65.109 with SMTP id w13mr19812969pas.21.1400663096973; Wed, 21 May 2014 02:04:56 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.16.173 with SMTP id 42ls620237qgb.62.gmail; Wed, 21 May 2014 02:04:56 -0700 (PDT) X-Received: by 10.220.94.146 with SMTP id z18mr243648vcm.40.1400663096787; Wed, 21 May 2014 02:04:56 -0700 (PDT) Received: from mail-vc0-f174.google.com (mail-vc0-f174.google.com [209.85.220.174]) by mx.google.com with ESMTPS id w3si265493vem.39.2014.05.21.02.04.56 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 21 May 2014 02:04:56 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.174 as permitted sender) client-ip=209.85.220.174; Received: by mail-vc0-f174.google.com with SMTP id lh14so2135855vcb.33 for ; Wed, 21 May 2014 02:04:56 -0700 (PDT) X-Received: by 10.221.64.80 with SMTP id xh16mr8673588vcb.35.1400663096593; Wed, 21 May 2014 02:04:56 -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 ib8csp96105vcb; Wed, 21 May 2014 02:04:55 -0700 (PDT) X-Received: by 10.66.244.176 with SMTP id xh16mr56847332pac.20.1400663095371; Wed, 21 May 2014 02:04:55 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id oq10si28285346pac.48.2014.05.21.02.04.54; Wed, 21 May 2014 02:04:54 -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 S1752191AbaEUJEo (ORCPT + 27 others); Wed, 21 May 2014 05:04:44 -0400 Received: from mail-qg0-f44.google.com ([209.85.192.44]:33224 "EHLO mail-qg0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752101AbaEUJEl (ORCPT ); Wed, 21 May 2014 05:04:41 -0400 Received: by mail-qg0-f44.google.com with SMTP id i50so2743734qgf.31 for ; Wed, 21 May 2014 02:04:40 -0700 (PDT) X-Received: by 10.140.81.74 with SMTP id e68mr63836873qgd.77.1400663080511; Wed, 21 May 2014 02:04:40 -0700 (PDT) Received: from localhost (ec2-23-23-178-99.compute-1.amazonaws.com. [23.23.178.99]) by mx.google.com with ESMTPSA id v44sm382893qge.13.2014.05.21.02.04.34 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Wed, 21 May 2014 02:04: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, dianders@chromium.org, linux@arm.linux.org.uk, nicolas.pitre@linaro.org, thomas.abraham@linaro.org, pdeschrijver@nvidia.com, Viresh Kumar Subject: [PATCH V4 1/3] cpufreq: handle calls to ->target_index() in separate routine Date: Wed, 21 May 2014 14:29:29 +0530 Message-Id: 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.220.174 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 Reviewed-by: Doug Anderson 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..ae11dd5 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: