diff options
author | Eduardo Valentin <eduardo.valentin@ti.com> | 2013-11-13 13:11:09 -0500 |
---|---|---|
committer | Zhang Rui <rui.zhang@intel.com> | 2014-01-01 22:54:14 -0500 |
commit | 1c9573a40c1d34494419f32560f28c763c504d79 (patch) | |
tree | ab8727f4e9452628a579ecea3dc560ebd1110d1c /drivers/thermal | |
parent | 06475b556cb4863cf1dcace9b2d21dac1fc74daf (diff) |
thermal: fix cpu_cooling max_level behavior
As per Documentation/thermal/sysfs-api.txt, max_level
is an index, not a counter. Thus, in case a CPU has
3 valid frequencies, max_level is expected to be 2, for instance.
The current code makes max_level == number of valid frequencies,
which is bogus. This patch fix the cpu_cooling device by
ranging max_level properly.
Reported-by: Carlos Hernandez <ceh@ti.com>
Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com>
Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Diffstat (limited to 'drivers/thermal')
-rw-r--r-- | drivers/thermal/cpu_cooling.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c index 02a46f23d14c..cc556a8e2842 100644 --- a/drivers/thermal/cpu_cooling.c +++ b/drivers/thermal/cpu_cooling.c | |||
@@ -173,6 +173,8 @@ static int get_property(unsigned int cpu, unsigned long input, | |||
173 | freq = table[i].frequency; | 173 | freq = table[i].frequency; |
174 | max_level++; | 174 | max_level++; |
175 | } | 175 | } |
176 | /* max_level is an index, not a counter */ | ||
177 | max_level--; | ||
176 | 178 | ||
177 | /* get max level */ | 179 | /* get max level */ |
178 | if (property == GET_MAXL) { | 180 | if (property == GET_MAXL) { |
@@ -181,7 +183,7 @@ static int get_property(unsigned int cpu, unsigned long input, | |||
181 | } | 183 | } |
182 | 184 | ||
183 | if (property == GET_FREQ) | 185 | if (property == GET_FREQ) |
184 | level = descend ? input : (max_level - input - 1); | 186 | level = descend ? input : (max_level - input); |
185 | 187 | ||
186 | for (i = 0, j = 0; table[i].frequency != CPUFREQ_TABLE_END; i++) { | 188 | for (i = 0, j = 0; table[i].frequency != CPUFREQ_TABLE_END; i++) { |
187 | /* ignore invalid entry */ | 189 | /* ignore invalid entry */ |
@@ -197,7 +199,7 @@ static int get_property(unsigned int cpu, unsigned long input, | |||
197 | 199 | ||
198 | if (property == GET_LEVEL && (unsigned int)input == freq) { | 200 | if (property == GET_LEVEL && (unsigned int)input == freq) { |
199 | /* get level by frequency */ | 201 | /* get level by frequency */ |
200 | *output = descend ? j : (max_level - j - 1); | 202 | *output = descend ? j : (max_level - j); |
201 | return 0; | 203 | return 0; |
202 | } | 204 | } |
203 | if (property == GET_FREQ && level == j) { | 205 | if (property == GET_FREQ && level == j) { |