Skip to content

Commit ff44f67

Browse files
wwillydlezcano
authored andcommitted
thermal/drivers/cpufreq_cooling: Fix return of cpufreq_set_cur_state
When setting the cooling device current state from userspace via sysfs, the operation fails by returning an -EINVAL. It appears the recent changes with the per-policy frequency QoS introduced a regression as reported by: https://lkml.org/lkml/2020/3/20/599 The function freq_qos_update_request returns 0 or 1 describing update effectiveness, and a negative error code on failure. However, cpufreq_set_cur_state returns 0 on success or an error code otherwise. Consider the QoS update as successful if the function does not return an error. Fixes: 3000ce3 ("cpufreq: Use per-policy frequency QoS") Signed-off-by: Willy Wolff <[email protected]> Acked-by: Viresh Kumar <[email protected]> Signed-off-by: Daniel Lezcano <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 2b8f1f0 commit ff44f67

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

drivers/thermal/cpufreq_cooling.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,7 @@ static int cpufreq_set_cur_state(struct thermal_cooling_device *cdev,
431431
unsigned long state)
432432
{
433433
struct cpufreq_cooling_device *cpufreq_cdev = cdev->devdata;
434+
int ret;
434435

435436
/* Request state should be less than max_level */
436437
if (WARN_ON(state > cpufreq_cdev->max_level))
@@ -442,8 +443,9 @@ static int cpufreq_set_cur_state(struct thermal_cooling_device *cdev,
442443

443444
cpufreq_cdev->cpufreq_state = state;
444445

445-
return freq_qos_update_request(&cpufreq_cdev->qos_req,
446-
get_state_freq(cpufreq_cdev, state));
446+
ret = freq_qos_update_request(&cpufreq_cdev->qos_req,
447+
get_state_freq(cpufreq_cdev, state));
448+
return ret < 0 ? ret : 0;
447449
}
448450

449451
/* Bind cpufreq callbacks to thermal cooling device ops */

0 commit comments

Comments
 (0)