Skip to contentSkip to conversation

thermal/drivers/cpufreq_cooling: Fix return of cpufreq_set_cur_state

PATCH In review Willy Wolff 4 participants 5 messages Mar 21, 2020 – Mar 24, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 thermal/drivers/cpufreq_cooling: Fix return of cpufreq_set_cur_state

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.

---
 drivers/thermal/cpufreq_cooling.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/thermal/cpufreq_cooling.c +4 -2
index fe83d7a210d4..af55ac08e1bd 100644
@@ -431,6 +431,7 @@ static int cpufreq_set_cur_state(struct thermal_cooling_device *cdev,
 				 unsigned long state)
 {
 	struct cpufreq_cooling_device *cpufreq_cdev = cdev->devdata;
+	int ret;
 
 	/* Request state should be less than max_level */
 	if (WARN_ON(state > cpufreq_cdev->max_level))
@@ -442,8 +443,9 @@ static int cpufreq_set_cur_state(struct thermal_cooling_device *cdev,
 
 	cpufreq_cdev->cpufreq_state = state;
 
-	return freq_qos_update_request(&cpufreq_cdev->qos_req,
-				get_state_freq(cpufreq_cdev, state));
+	ret = freq_qos_update_request(&cpufreq_cdev->qos_req,
+				      get_state_freq(cpufreq_cdev, state));
+	return ret < 0 ? ret : 0;
 }
 
 /* Bind cpufreq callbacks to thermal cooling device ops */
Signature · 1 line
2.20.1
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 23 lines · Willy Wolff

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.

---
 drivers/thermal/cpufreq_cooling.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/thermal/cpufreq_cooling.c +1 -0
index fe83d7a210d4..af55ac08e1bd 100644
@@ -431,6 +431,7 @@ static int cpufreq_set_cur_state(struct thermal_cooling_device *cdev,
 				 unsigned long state)
 {
 	struct cpufreq_cooling_device *cpufreq_cdev = cdev->devdata;
+	int ret;
 
 	/* Request state should be less than max_level */
 	if (WARN_ON(state > cpufreq_cdev->max_level))
@@ -442,8 +443,9 @@ static int cpufreq_set_cur_state(struct thermal_cooling_device *cdev,
 

drivers/thermal/cpufreq_cooling.c static int cpufreq_set_cur_state(struct thermal_cooling_device *cdev, · line 451

Quoted 10 lines
drivers/thermal/cpufreq_cooling.c +3 -2
 	cpufreq_cdev->cpufreq_state = state;
 
-	return freq_qos_update_request(&cpufreq_cdev->qos_req,
-				get_state_freq(cpufreq_cdev, state));
+	ret = freq_qos_update_request(&cpufreq_cdev->qos_req,
+				      get_state_freq(cpufreq_cdev, state));
+	return ret < 0 ? ret : 0;
 }
 
 /* Bind cpufreq callbacks to thermal cooling device ops */
Signature · 1 line
viresh
#2 lore raw
In reply to Willy Wolff

Hi Willy,

Quoted 5 lines · Willy Wolff

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.

Please improve the commit message with context from your earlier bug report thread and a summary of how the problem shows up.

Thanks,
Amit

Quoted 32 lines
---
 drivers/thermal/cpufreq_cooling.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/thermal/cpufreq_cooling.c +4 -3
index fe83d7a210d4..af55ac08e1bd 100644
@@ -431,6 +431,7 @@ static int cpufreq_set_cur_state(struct thermal_cooling_device *cdev,
                                 unsigned long state)
 {
        struct cpufreq_cooling_device *cpufreq_cdev = cdev->devdata;
+       int ret;
 
        /* Request state should be less than max_level */
        if (WARN_ON(state > cpufreq_cdev->max_level))
@@ -442,8 +443,9 @@ static int cpufreq_set_cur_state(struct thermal_cooling_device *cdev,
 
        cpufreq_cdev->cpufreq_state = state;
 
-       return freq_qos_update_request(&cpufreq_cdev->qos_req,
-                               get_state_freq(cpufreq_cdev, state));
+       ret = freq_qos_update_request(&cpufreq_cdev->qos_req,
+                                     get_state_freq(cpufreq_cdev, state));
+       return ret < 0 ? ret : 0;
 }
 
 /* Bind cpufreq callbacks to thermal cooling device ops */
--

2.20.1

#3 lore raw
Quoted 11 lines · Amit Kucheria

Hi Willy,

Quoted 5 lines · Willy Wolff

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.

Please improve the commit message with context from your earlier bug report thread and a summary of how the problem shows up.

I've improved the commit message when applied:

https://git.kernel.org/pub/scm/linux/kernel/git/thermal/linux.git/commit/?h=testing&id=ff44f672d74178b3be19d41a169b98b3e391d4ce

Quoted 32 lines
Quoted 32 lines
---
 drivers/thermal/cpufreq_cooling.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/thermal/cpufreq_cooling.c +4 -3
index fe83d7a210d4..af55ac08e1bd 100644
@@ -431,6 +431,7 @@ static int cpufreq_set_cur_state(struct thermal_cooling_device *cdev,
                                 unsigned long state)
 {
        struct cpufreq_cooling_device *cpufreq_cdev = cdev->devdata;
+       int ret;
 
        /* Request state should be less than max_level */
        if (WARN_ON(state > cpufreq_cdev->max_level))
@@ -442,8 +443,9 @@ static int cpufreq_set_cur_state(struct thermal_cooling_device *cdev,
 
        cpufreq_cdev->cpufreq_state = state;
 
-       return freq_qos_update_request(&cpufreq_cdev->qos_req,
-                               get_state_freq(cpufreq_cdev, state));
+       ret = freq_qos_update_request(&cpufreq_cdev->qos_req,
+                                     get_state_freq(cpufreq_cdev, state));
+       return ret < 0 ? ret : 0;
 }
 
 /* Bind cpufreq callbacks to thermal cooling device ops */
--

2.20.1

Signature · 5 lines
 <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog
#4 lore raw

Many thanks.

Quoted 58 lines · Daniel Lezcano
Quoted 11 lines · Amit Kucheria

Hi Willy,

Quoted 5 lines · Willy Wolff

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.

Please improve the commit message with context from your earlier bug report thread and a summary of how the problem shows up.

I've improved the commit message when applied:

https://git.kernel.org/pub/scm/linux/kernel/git/thermal/linux.git/commit/?h=testing&id=ff44f672d74178b3be19d41a169b98b3e391d4ce

Quoted 32 lines
Quoted 32 lines
---
 drivers/thermal/cpufreq_cooling.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/thermal/cpufreq_cooling.c +4 -3
index fe83d7a210d4..af55ac08e1bd 100644
@@ -431,6 +431,7 @@ static int cpufreq_set_cur_state(struct thermal_cooling_device *cdev,
                                 unsigned long state)
 {
        struct cpufreq_cooling_device *cpufreq_cdev = cdev->devdata;
+       int ret;
 
        /* Request state should be less than max_level */
        if (WARN_ON(state > cpufreq_cdev->max_level))
@@ -442,8 +443,9 @@ static int cpufreq_set_cur_state(struct thermal_cooling_device *cdev,
 
        cpufreq_cdev->cpufreq_state = state;
 
-       return freq_qos_update_request(&cpufreq_cdev->qos_req,
-                               get_state_freq(cpufreq_cdev, state));
+       ret = freq_qos_update_request(&cpufreq_cdev->qos_req,
+                                     get_state_freq(cpufreq_cdev, state));
+       return ret < 0 ? ret : 0;
 }
 
 /* Bind cpufreq callbacks to thermal cooling device ops */
--

2.20.1

Signature · 5 lines
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog