Commit da27f69d authored by Viresh Kumar's avatar Viresh Kumar Committed by Eduardo Valentin

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: default avatarViresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: default avatarLukasz Luba <lukasz.luba@arm.com>
Tested-by: default avatarLukasz Luba <lukasz.luba@arm.com>
Signed-off-by: default avatarEduardo Valentin <edubezval@gmail.com>
parent 81ee14da
...@@ -119,22 +119,19 @@ static LIST_HEAD(cpufreq_cdev_list); ...@@ -119,22 +119,19 @@ static LIST_HEAD(cpufreq_cdev_list);
* @cpufreq_cdev: cpufreq_cdev for which the property is required * @cpufreq_cdev: cpufreq_cdev for which the property is required
* @freq: Frequency * @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, static unsigned long get_level(struct cpufreq_cooling_device *cpufreq_cdev,
unsigned int freq) unsigned int freq)
{ {
struct freq_table *freq_table = cpufreq_cdev->freq_table;
unsigned long level; unsigned long level;
for (level = 0; level <= cpufreq_cdev->max_level; level++) { for (level = 1; level <= cpufreq_cdev->max_level; level++)
if (freq == cpufreq_cdev->freq_table[level].frequency) if (freq > freq_table[level].frequency)
return level;
if (freq > cpufreq_cdev->freq_table[level].frequency)
break; break;
}
return THERMAL_CSTATE_INVALID; return level - 1;
} }
/** /**
...@@ -627,13 +624,6 @@ static int cpufreq_power2state(struct thermal_cooling_device *cdev, ...@@ -627,13 +624,6 @@ static int cpufreq_power2state(struct thermal_cooling_device *cdev,
target_freq = cpu_power_to_freq(cpufreq_cdev, normalised_power); target_freq = cpu_power_to_freq(cpufreq_cdev, normalised_power);
*state = get_level(cpufreq_cdev, target_freq); *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, trace_thermal_power_cpu_limit(policy->related_cpus, target_freq, *state,
power); power);
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment