@@ -277,26 +277,22 @@ static int cpufreq_get_max_state(struct thermal_cooling_device *cdev,
{
struct cpufreq_cooling_device *cpufreq_device = cdev->devdata;
struct cpumask *maskPtr = &cpufreq_device->allowed_cpus;
- unsigned int cpu;
struct cpufreq_frequency_table *table;
- unsigned long count = 0;
+ unsigned int cpu;
int i = 0;
cpu = cpumask_any(maskPtr);
- table = cpufreq_frequency_get_table(cpu);
- if (!table) {
- *state = 0;
- return 0;
- }
+ table = get_cpu_cooling_table(cpu);
+ if (IS_ERR(table))
+ return -EINVAL;
- for (i = 0; (table[i].frequency != CPUFREQ_TABLE_END); i++) {
- if (table[i].frequency == CPUFREQ_ENTRY_INVALID)
- continue;
- count++;
- }
+ while (table[i].frequency != CPUFREQ_TABLE_END)
+ i++;
+
+ kfree(table);
- if (count > 0) {
- *state = --count;
+ if (i > 0) {
+ *state = --i;
return 0;
}
Signed-off-by: Zhang Rui <rui.zhang@intel.com> --- drivers/thermal/cpu_cooling.c | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-)