* [PATCH] thermal: cpu_cooling: fix 'descend' check in get_property()
@ 2013-05-28 6:22 Shawn Guo
2013-05-28 6:48 ` Zhang Rui
0 siblings, 1 reply; 2+ messages in thread
From: Shawn Guo @ 2013-05-28 6:22 UTC (permalink / raw)
To: linux-arm-kernel
The variable 'descend' is initialized as -1 in function get_property(),
and will never get any chance to be updated by the following code.
if (freq != CPUFREQ_ENTRY_INVALID && descend != -1)
descend = !!(freq > table[i].frequency);
This makes function get_property() return the wrong frequency for given
cooling level if the frequency table is sorted in ascending. Fix it
by correcting the 'descend' check in if-condition to 'descend == -1'.
Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
---
drivers/thermal/cpu_cooling.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c
index c94bf2e..82e15db 100644
--- a/drivers/thermal/cpu_cooling.c
+++ b/drivers/thermal/cpu_cooling.c
@@ -167,7 +167,7 @@ static int get_property(unsigned int cpu, unsigned long input,
continue;
/* get the frequency order */
- if (freq != CPUFREQ_ENTRY_INVALID && descend != -1)
+ if (freq != CPUFREQ_ENTRY_INVALID && descend == -1)
descend = !!(freq > table[i].frequency);
freq = table[i].frequency;
--
1.7.9.5
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [PATCH] thermal: cpu_cooling: fix 'descend' check in get_property()
2013-05-28 6:22 [PATCH] thermal: cpu_cooling: fix 'descend' check in get_property() Shawn Guo
@ 2013-05-28 6:48 ` Zhang Rui
0 siblings, 0 replies; 2+ messages in thread
From: Zhang Rui @ 2013-05-28 6:48 UTC (permalink / raw)
To: linux-arm-kernel
On Tue, 2013-05-28 at 14:22 +0800, Shawn Guo wrote:
> The variable 'descend' is initialized as -1 in function get_property(),
> and will never get any chance to be updated by the following code.
>
> if (freq != CPUFREQ_ENTRY_INVALID && descend != -1)
> descend = !!(freq > table[i].frequency);
>
> This makes function get_property() return the wrong frequency for given
> cooling level if the frequency table is sorted in ascending. Fix it
> by correcting the 'descend' check in if-condition to 'descend == -1'.
>
> Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
good catch!
patch applied to thermal -next.
thanks,
rui
> ---
> drivers/thermal/cpu_cooling.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c
> index c94bf2e..82e15db 100644
> --- a/drivers/thermal/cpu_cooling.c
> +++ b/drivers/thermal/cpu_cooling.c
> @@ -167,7 +167,7 @@ static int get_property(unsigned int cpu, unsigned long input,
> continue;
>
> /* get the frequency order */
> - if (freq != CPUFREQ_ENTRY_INVALID && descend != -1)
> + if (freq != CPUFREQ_ENTRY_INVALID && descend == -1)
> descend = !!(freq > table[i].frequency);
>
> freq = table[i].frequency;
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-05-28 6:48 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-05-28 6:22 [PATCH] thermal: cpu_cooling: fix 'descend' check in get_property() Shawn Guo
2013-05-28 6:48 ` Zhang Rui
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).