diff mbox

cpufreq: Fix incorrect usage of clamp_val()

Message ID a5c21ebe773d364b49bc5df9c4f69ff2eb181dbb.1464693539.git.viresh.kumar@linaro.org (mailing list archive)
State Not Applicable, archived
Headers show

Commit Message

Viresh Kumar May 31, 2016, 11:19 a.m. UTC
clamp_val() doesn't change anything by itself, rather it returns the
clamped value.

Fix it.

Fixes: 0ac587b32f49 ("cpufreq: Use clamp_val() in __cpufreq_driver_target()")
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
Hi Rafael,

Please merge this with the offending commit if you are fine with rebase,
else apply this one as well.

Sorry for blindly copying code.

 drivers/cpufreq/cpufreq.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Steve Muckle May 31, 2016, 6:23 p.m. UTC | #1
On Tue, May 31, 2016 at 04:49:42PM +0530, Viresh Kumar wrote:
> clamp_val() doesn't change anything by itself, rather it returns the
> clamped value.
> 
> Fix it.
> 
> Fixes: 0ac587b32f49 ("cpufreq: Use clamp_val() in __cpufreq_driver_target()")
> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
> ---
> Hi Rafael,
> 
> Please merge this with the offending commit if you are fine with rebase,
> else apply this one as well.
> 
> Sorry for blindly copying code.
> 
>  drivers/cpufreq/cpufreq.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
> index d0c02a7eec0f..c6a14ba239a2 100644
> --- a/drivers/cpufreq/cpufreq.c
> +++ b/drivers/cpufreq/cpufreq.c
> @@ -1927,7 +1927,7 @@ int __cpufreq_driver_target(struct cpufreq_policy *policy,
>  		return -ENODEV;
>  
>  	/* Make sure that target_freq is within supported range */
> -	clamp_val(target_freq, policy->min, policy->max);
> +	target_freq = clamp_val(target_freq, policy->min, policy->max);
>  
>  	pr_debug("target for CPU %u: %u kHz, relation %u, requested %u kHz\n",
>  		 policy->cpu, target_freq, relation, old_target_freq);

As mentioned in the other thread cpufreq_driver_fast_switch() has this
problem as well, might as well fix it in this patch also.

thanks,
Steve
--
To unsubscribe from this list: send the line "unsubscribe linux-pm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Rafael J. Wysocki May 31, 2016, 8:44 p.m. UTC | #2
On Tuesday, May 31, 2016 04:49:42 PM Viresh Kumar wrote:
> clamp_val() doesn't change anything by itself, rather it returns the
> clamped value.
> 
> Fix it.
> 
> Fixes: 0ac587b32f49 ("cpufreq: Use clamp_val() in __cpufreq_driver_target()")
> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
> ---
> Hi Rafael,
> 
> Please merge this with the offending commit if you are fine with rebase,
> else apply this one as well.

Done.

> Sorry for blindly copying code.

Well, I got that wrong myself after all ...

Thanks,
Rafael

--
To unsubscribe from this list: send the line "unsubscribe linux-pm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index d0c02a7eec0f..c6a14ba239a2 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -1927,7 +1927,7 @@  int __cpufreq_driver_target(struct cpufreq_policy *policy,
 		return -ENODEV;
 
 	/* Make sure that target_freq is within supported range */
-	clamp_val(target_freq, policy->min, policy->max);
+	target_freq = clamp_val(target_freq, policy->min, policy->max);
 
 	pr_debug("target for CPU %u: %u kHz, relation %u, requested %u kHz\n",
 		 policy->cpu, target_freq, relation, old_target_freq);