mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-05 08:26:59 +00:00
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>
This commit is contained in:
parent
53ca1ece60
commit
cb1b631864
1 changed files with 4 additions and 3 deletions
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue