* [PATCH] thermal: exynos: fix handling of invalid frequency table entries
@ 2013-04-09 21:59 Andrew Bresticker
2013-04-10 2:06 ` Zhang Rui
0 siblings, 1 reply; 3+ messages in thread
From: Andrew Bresticker @ 2013-04-09 21:59 UTC (permalink / raw)
To: Zhang Rui, Eduardo Valentin, Kukjin Kim
Cc: linux-pm, linux-kernel, linux-samsung-soc, Andrew Bresticker
Similar to the error described in "thermal: cpu_cooling: fix handling
of invalid frequency table entries," exynos_get_frequency_level() will
enter an infinite loop if any CPU frequency table entries are invalid.
This patch fixes the handling of invalid frequency entries so that
there is no infinite loop and the correct level is returned.
Signed-off-by: Andrew Bresticker <abrestic@chromium.org>
---
drivers/thermal/exynos_thermal.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/thermal/exynos_thermal.c b/drivers/thermal/exynos_thermal.c
index d5e6267..524b2a0 100644
--- a/drivers/thermal/exynos_thermal.c
+++ b/drivers/thermal/exynos_thermal.c
@@ -237,7 +237,7 @@ static int exynos_get_crit_temp(struct thermal_zone_device *thermal,
static int exynos_get_frequency_level(unsigned int cpu, unsigned int freq)
{
- int i = 0, ret = -EINVAL;
+ int i, level = 0, ret = -EINVAL;
struct cpufreq_frequency_table *table = NULL;
#ifdef CONFIG_CPU_FREQ
table = cpufreq_frequency_get_table(cpu);
@@ -245,12 +245,12 @@ static int exynos_get_frequency_level(unsigned int cpu, unsigned int freq)
if (!table)
return ret;
- while (table[i].frequency != CPUFREQ_TABLE_END) {
+ for (i = 0; table[i].frequency != CPUFREQ_TABLE_END; i++) {
if (table[i].frequency == CPUFREQ_ENTRY_INVALID)
continue;
if (table[i].frequency == freq)
- return i;
- i++;
+ return level;
+ level++;
}
return ret;
}
--
1.8.1.3
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] thermal: exynos: fix handling of invalid frequency table entries
2013-04-09 21:59 [PATCH] thermal: exynos: fix handling of invalid frequency table entries Andrew Bresticker
@ 2013-04-10 2:06 ` Zhang Rui
2013-04-11 18:40 ` Andrew Bresticker
0 siblings, 1 reply; 3+ messages in thread
From: Zhang Rui @ 2013-04-10 2:06 UTC (permalink / raw)
To: Andrew Bresticker
Cc: Eduardo Valentin, Kukjin Kim, linux-pm, linux-kernel, linux-samsung-soc
Hi, Andrew,
can you please verify
commit fc35b35cbe24ef021ea9acfba21e54da958df747
commit 57df8106932b57427df1eaaa13871857f75b1194
at
http://git.kernel.org/cgit/linux/kernel/git/rzhang/linux.git/log/?h=thermal
fixes the problem for you?
thanks,
rui
On Tue, 2013-04-09 at 14:59 -0700, Andrew Bresticker wrote:
> Similar to the error described in "thermal: cpu_cooling: fix handling
> of invalid frequency table entries," exynos_get_frequency_level() will
> enter an infinite loop if any CPU frequency table entries are invalid.
> This patch fixes the handling of invalid frequency entries so that
> there is no infinite loop and the correct level is returned.
>
> Signed-off-by: Andrew Bresticker <abrestic@chromium.org>
> ---
> drivers/thermal/exynos_thermal.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/thermal/exynos_thermal.c b/drivers/thermal/exynos_thermal.c
> index d5e6267..524b2a0 100644
> --- a/drivers/thermal/exynos_thermal.c
> +++ b/drivers/thermal/exynos_thermal.c
> @@ -237,7 +237,7 @@ static int exynos_get_crit_temp(struct thermal_zone_device *thermal,
>
> static int exynos_get_frequency_level(unsigned int cpu, unsigned int freq)
> {
> - int i = 0, ret = -EINVAL;
> + int i, level = 0, ret = -EINVAL;
> struct cpufreq_frequency_table *table = NULL;
> #ifdef CONFIG_CPU_FREQ
> table = cpufreq_frequency_get_table(cpu);
> @@ -245,12 +245,12 @@ static int exynos_get_frequency_level(unsigned int cpu, unsigned int freq)
> if (!table)
> return ret;
>
> - while (table[i].frequency != CPUFREQ_TABLE_END) {
> + for (i = 0; table[i].frequency != CPUFREQ_TABLE_END; i++) {
> if (table[i].frequency == CPUFREQ_ENTRY_INVALID)
> continue;
> if (table[i].frequency == freq)
> - return i;
> - i++;
> + return level;
> + level++;
> }
> return ret;
> }
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] thermal: exynos: fix handling of invalid frequency table entries
2013-04-10 2:06 ` Zhang Rui
@ 2013-04-11 18:40 ` Andrew Bresticker
0 siblings, 0 replies; 3+ messages in thread
From: Andrew Bresticker @ 2013-04-11 18:40 UTC (permalink / raw)
To: Zhang Rui
Cc: Eduardo Valentin, Kukjin Kim, linux-pm, linux-kernel, linux-samsung-soc
> can you please verify
> commit fc35b35cbe24ef021ea9acfba21e54da958df747
> commit 57df8106932b57427df1eaaa13871857f75b1194
> at
> http://git.kernel.org/cgit/linux/kernel/git/rzhang/linux.git/log/?h=thermal
> fixes the problem for you?
It does. Thanks!
-Andrew
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-04-11 18:40 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-04-09 21:59 [PATCH] thermal: exynos: fix handling of invalid frequency table entries Andrew Bresticker
2013-04-10 2:06 ` Zhang Rui
2013-04-11 18:40 ` Andrew Bresticker
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).