Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1601942 > unrolled thread

[PATCH 16/17] thermal: cpu_cooling: 'freq' can't be zero in cpufreq_state2power()

Started byViresh Kumar <viresh.kumar@linaro.org>
First post2017-03-16 06:40 +0100
Last post2017-03-16 06:40 +0100
Articles 1 — 1 participant

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH 16/17] thermal: cpu_cooling: 'freq' can't be zero in cpufreq_state2power() Viresh Kumar <viresh.kumar@linaro.org> - 2017-03-16 06:40 +0100

#1601942 — [PATCH 16/17] thermal: cpu_cooling: 'freq' can't be zero in cpufreq_state2power()

FromViresh Kumar <viresh.kumar@linaro.org>
Date2017-03-16 06:40 +0100
Subject[PATCH 16/17] thermal: cpu_cooling: 'freq' can't be zero in cpufreq_state2power()
Message-ID<tlwiJ-223-23@gated-at.bofh.it>
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 fb535fd5aa12..768a95bcc392 100644
--- a/drivers/thermal/cpu_cooling.c
+++ b/drivers/thermal/cpu_cooling.c
@@ -561,12 +561,13 @@ static int cpufreq_state2power(struct thermal_cooling_device *cdev,
 	int ret;
 	struct cpufreq_cooling_device *cpufreq_dev = cdev->devdata;
 
+	/* Request state should be less than max_level */
+	if (WARN_ON(state > cpufreq_dev->max_level))
+		return -EINVAL;
+
 	num_cpus = cpumask_weight(cpufreq_dev->policy->cpus);
 
 	freq = cpufreq_dev->freq_table[state].frequency;
-	if (!freq)
-		return -EINVAL;
-
 	dynamic_power = cpu_freq_to_power(cpufreq_dev, freq) * num_cpus;
 	ret = get_static_power(cpufreq_dev, tz, freq, &static_power);
 	if (ret)
-- 
2.7.1.410.g6faf27b

[toc] | [standalone]


Back to top | Article view | linux.kernel


csiph-web