Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1625825
| From | Viresh Kumar <viresh.kumar@linaro.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH V3 16/17] thermal: cpu_cooling: 'freq' can't be zero in cpufreq_state2power() |
| Date | 2017-04-19 07:40 +0200 |
| Message-ID | <txQvn-7M4-1@gated-at.bofh.it> (permalink) |
| References | <txQvn-7M4-3@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
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> --- drivers/thermal/cpu_cooling.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c index c85b217d16c8..dc73405b04f2 100644 --- a/drivers/thermal/cpu_cooling.c +++ b/drivers/thermal/cpu_cooling.c @@ -560,12 +560,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) -- 2.12.0.432.g71c3a4f4ba37
Back to linux.kernel | Previous | Next | Find similar | Unroll thread
[PATCH V3 16/17] thermal: cpu_cooling: 'freq' can't be zero in cpufreq_state2power() Viresh Kumar <viresh.kumar@linaro.org> - 2017-04-19 07:40 +0200
csiph-web