Re: [PATCH V4 1/3] cpufreq: handle calls to ->target_index() in separate routine

2014-05-26 Thread Viresh Kumar
On 27 May 2014 04:51, Rafael J. Wysocki  wrote:
> I guess I can take this one without the rest of the series?

Yes.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH V4 1/3] cpufreq: handle calls to ->target_index() in separate routine

2014-05-26 Thread Rafael J. Wysocki
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 
> Reviewed-by: Doug Anderson 
> Signed-off-by: Viresh Kumar 

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, );
> + }
> +
> + 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, , 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, );
> - }
> -
> - 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, , retval);
> + retval = __target_index(policy, freq_table, index);
>   }
>  
>  out:
> 

-- 
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH V4 1/3] cpufreq: handle calls to -target_index() in separate routine

2014-05-26 Thread Rafael J. Wysocki
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 swar...@nvidia.com
 Reviewed-by: Doug Anderson diand...@chromium.org
 Signed-off-by: Viresh Kumar viresh.ku...@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.
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH V4 1/3] cpufreq: handle calls to -target_index() in separate routine

2014-05-26 Thread Viresh Kumar
On 27 May 2014 04:51, Rafael J. Wysocki r...@rjwysocki.net wrote:
 I guess I can take this one without the rest of the series?

Yes.
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH V4 1/3] cpufreq: handle calls to ->target_index() in separate routine

2014-05-21 Thread Viresh Kumar
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, );
+   }
+
+   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, , 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, );
-   }
-
-   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, , retval);
+   retval = __target_index(policy, freq_table, index);
}
 
 out:
-- 
2.0.0.rc2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH V4 1/3] cpufreq: handle calls to -target_index() in separate routine

2014-05-21 Thread Viresh Kumar
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 swar...@nvidia.com
Reviewed-by: Doug Anderson diand...@chromium.org
Signed-off-by: Viresh Kumar viresh.ku...@linaro.org
---
 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:
-- 
2.0.0.rc2

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/