summaryrefslogtreecommitdiff
path: root/drivers/thermal/cpu_cooling.c
diff options
context:
space:
mode:
authorViresh Kumar <viresh.kumar@linaro.org>2017-04-25 15:57:21 +0530
committerEduardo Valentin <edubezval@gmail.com>2017-05-27 17:32:52 -0700
commitda27f69d6a4eaf7bdaaad9d9e1b997a1c8f186aa (patch)
treec315bd1e48c8de4006cef943724c94a7ff9cd7d5 /drivers/thermal/cpu_cooling.c
parent81ee14da1051ee87c243b9a0e55d83f1aa274b76 (diff)
thermal: cpu_cooling: get_level() can't fail
The frequency passed to get_level() is returned by cpu_power_to_freq() and it is guaranteed that get_level() can't fail. Get rid of error code. 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/cpu_cooling.c')
-rw-r--r--drivers/thermal/cpu_cooling.c20
1 files changed, 5 insertions, 15 deletions
diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c
index 11735dba1456..2c2d76ac04c3 100644
--- a/drivers/thermal/cpu_cooling.c
+++ b/drivers/thermal/cpu_cooling.c
@@ -119,22 +119,19 @@ static LIST_HEAD(cpufreq_cdev_list);
* @cpufreq_cdev: cpufreq_cdev for which the property is required
* @freq: Frequency
*
- * Return: level on success, THERMAL_CSTATE_INVALID on error.
+ * Return: level corresponding to the frequency.
*/
static unsigned long get_level(struct cpufreq_cooling_device *cpufreq_cdev,
unsigned int freq)
{
+ struct freq_table *freq_table = cpufreq_cdev->freq_table;
unsigned long level;
- for (level = 0; level <= cpufreq_cdev->max_level; level++) {
- if (freq == cpufreq_cdev->freq_table[level].frequency)
- return level;
-
- if (freq > cpufreq_cdev->freq_table[level].frequency)
+ for (level = 1; level <= cpufreq_cdev->max_level; level++)
+ if (freq > freq_table[level].frequency)
break;
- }
- return THERMAL_CSTATE_INVALID;
+ return level - 1;
}
/**
@@ -627,13 +624,6 @@ static int cpufreq_power2state(struct thermal_cooling_device *cdev,
target_freq = cpu_power_to_freq(cpufreq_cdev, normalised_power);
*state = get_level(cpufreq_cdev, target_freq);
- if (*state == THERMAL_CSTATE_INVALID) {
- dev_err_ratelimited(&cdev->device,
- "Failed to convert %dKHz for cpu %d into a cdev state\n",
- target_freq, policy->cpu);
- return -EINVAL;
- }
-
trace_thermal_power_cpu_limit(policy->related_cpus, target_freq, *state,
power);
return 0;