Linux Power Management development
 help / color / mirror / Atom feed
From: "Rafael J. Wysocki" <rjw@rjwysocki.net>
To: Viresh Kumar <viresh.kumar@linaro.org>
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
Subject: Re: [PATCH V4 1/3] cpufreq: handle calls to ->target_index() in separate routine
Date: Tue, 27 May 2014 01:21:31 +0200	[thread overview]
Message-ID: <2164172.cubRkjSW1o@vostro.rjw.lan> (raw)
In-Reply-To: <b2ed4e111222c2367a77a1382a6a7ea232ef9b59.1400662383.git.viresh.kumar@linaro.org>

On Wednesday, May 21, 2014 02:29:29 PM Viresh Kumar wrote:
> 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 <swarren@nvidia.com>
> Reviewed-by: Doug Anderson <dianders@chromium.org>
> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>

I guess I can take this one without the rest of the series?

> ---
>  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:
> 

-- 
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.

  reply	other threads:[~2014-05-26 23:04 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-21  8:59 [PATCH V4 0/3] cpufreq: add support for intermediate (stable) frequencies Viresh Kumar
2014-05-21  8:59 ` [PATCH V4 1/3] cpufreq: handle calls to ->target_index() in separate routine Viresh Kumar
2014-05-26 23:21   ` Rafael J. Wysocki [this message]
2014-05-26 23:59     ` Viresh Kumar
2014-05-21  8:59 ` [PATCH V4 2/3] cpufreq: add support for intermediate (stable) frequencies Viresh Kumar
2014-05-22 16:37   ` Stephen Warren
2014-05-23  4:24     ` Viresh Kumar
2014-05-23 15:56       ` Stephen Warren
2014-05-26  4:01         ` Viresh Kumar
2014-05-28 19:40   ` Doug Anderson
2014-05-30  1:19     ` Viresh Kumar
2014-05-21  8:59 ` [PATCH V4 3/3] cpufreq: Tegra: implement intermediate frequency callbacks Viresh Kumar
2014-05-22 16:39   ` Stephen Warren
2014-05-23  4:05     ` Viresh Kumar
2014-05-29 17:42       ` Stephen Warren
2014-06-02 10:01         ` Viresh Kumar
2014-05-29 17:40   ` Stephen Warren
2014-05-30  1:56     ` Viresh Kumar
2014-05-30 16:26       ` Stephen Warren
2014-06-02 10:06         ` Viresh Kumar
2014-06-02 16:50           ` Stephen Warren

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2164172.cubRkjSW1o@vostro.rjw.lan \
    --to=rjw@rjwysocki.net \
    --cc=arvind.chauhan@arm.com \
    --cc=dianders@chromium.org \
    --cc=linaro-kernel@lists.linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    --cc=nicolas.pitre@linaro.org \
    --cc=pdeschrijver@nvidia.com \
    --cc=swarren@nvidia.com \
    --cc=thomas.abraham@linaro.org \
    --cc=viresh.kumar@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox