summaryrefslogtreecommitdiff
path: root/drivers/thermal
diff options
context:
space:
mode:
authorViresh Kumar <viresh.kumar@linaro.org>2017-04-25 13:27:23 +0300
committerEduardo Valentin <edubezval@gmail.com>2017-05-28 03:32:59 +0300
commitcb1b631864ad7e34324ceccb73d0226dd00ad90d (patch)
tree5c1c1834844c1c7d86ac7e6fc8750998c4a84bee /drivers/thermal
parent53ca1ece60a719e23f686c647cb05d9e12a31974 (diff)
downloadlinux-cb1b631864ad7e34324ceccb73d0226dd00ad90d.tar.xz
thermal: cpu_cooling: 'freq' can't be zero in cpufreq_state2power()
The frequency table shouldn't have any zero frequency entries and so such a check isn't required. Though it would be better to make sure 'state' is within limits. Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Reviewed-by: Lukasz Luba <lukasz.luba@arm.com> Tested-by: Lukasz Luba <lukasz.luba@arm.com> Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
Diffstat (limited to 'drivers/thermal')
-rw-r--r--drivers/thermal/cpu_cooling.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c
index bfa9731e7cdb..9cbf7bdbeb7a 100644
--- a/drivers/thermal/cpu_cooling.c
+++ b/drivers/thermal/cpu_cooling.c
@@ -564,12 +564,13 @@ static int cpufreq_state2power(struct thermal_cooling_device *cdev,
int ret;
struct cpufreq_cooling_device *cpufreq_cdev = cdev->devdata;
+ /* Request state should be less than max_level */
+ if (WARN_ON(state > cpufreq_cdev->max_level))
+ return -EINVAL;
+
num_cpus = cpumask_weight(cpufreq_cdev->policy->cpus);
freq = cpufreq_cdev->freq_table[state].frequency;
- if (!freq)
- return -EINVAL;
-
dynamic_power = cpu_freq_to_power(cpufreq_cdev, freq) * num_cpus;
ret = get_static_power(cpufreq_cdev, tz, freq, &static_power);
if (ret)