diff mbox

[11/26] cpu_cooling: propagate error returned by idr_alloc()

Message ID 1cfc99a9a641f2937a8ac95c6b784e3eee033b0c.1417167599.git.viresh.kumar@linaro.org (mailing list archive)
State Changes Requested
Delegated to: Eduardo Valentin
Headers show

Commit Message

Viresh Kumar Nov. 28, 2014, 9:44 a.m. UTC
We aren't supposed to return our own error type here. Return what we got.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 drivers/thermal/cpu_cooling.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Javi Merino Dec. 2, 2014, 3:35 p.m. UTC | #1
On Fri, Nov 28, 2014 at 09:44:05AM +0000, Viresh Kumar wrote:
> We aren't supposed to return our own error type here. Return what we got.
> 
> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
> ---
>  drivers/thermal/cpu_cooling.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c
> index bb11dd4..964586f 100644
> --- a/drivers/thermal/cpu_cooling.c
> +++ b/drivers/thermal/cpu_cooling.c
> @@ -477,7 +477,7 @@ __cpufreq_cooling_register(struct device_node *np,
>  	ret = get_idr(&cpufreq_idr, &cpufreq_dev->id);
>  	if (ret) {
>  		kfree(cpufreq_dev);
> -		return ERR_PTR(-EINVAL);
> +		return ERR_PTR(cpufreq_dev->id);

The error is ret, not the id which is probably 0 if there was an
error. So:

+		return ERR_PTR(ret);

Cheers,
Javi

--
To unsubscribe from this list: send the line "unsubscribe linux-pm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Eduardo Valentin Dec. 2, 2014, 11:03 p.m. UTC | #2
Hello Viresh,

On Fri, Nov 28, 2014 at 03:14:05PM +0530, Viresh Kumar wrote:
> We aren't supposed to return our own error type here. Return what we got.
> 

OK..

> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
> ---
>  drivers/thermal/cpu_cooling.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c
> index bb11dd4..964586f 100644
> --- a/drivers/thermal/cpu_cooling.c
> +++ b/drivers/thermal/cpu_cooling.c
> @@ -477,7 +477,7 @@ __cpufreq_cooling_register(struct device_node *np,
>  	ret = get_idr(&cpufreq_idr, &cpufreq_dev->id);
>  	if (ret) {
>  		kfree(cpufreq_dev);
> -		return ERR_PTR(-EINVAL);
> +		return ERR_PTR(cpufreq_dev->id);

cpufreq_dev is an invalid object here. Maybe you want to use ret in your
patch?
>  	}
>  
>  	snprintf(dev_name, sizeof(dev_name), "thermal-cpufreq-%d",
> -- 
> 2.0.3.693.g996b0fd
>
Viresh Kumar Dec. 3, 2014, 4:36 a.m. UTC | #3
On 2 December 2014 at 21:05, Javi Merino <javi.merino@arm.com> wrote:
> The error is ret, not the id which is probably 0 if there was an
> error. So:
>
> +               return ERR_PTR(ret);

Where should I hide my face, shameful mistake :(
--
To unsubscribe from this list: send the line "unsubscribe linux-pm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c
index bb11dd4..964586f 100644
--- a/drivers/thermal/cpu_cooling.c
+++ b/drivers/thermal/cpu_cooling.c
@@ -477,7 +477,7 @@  __cpufreq_cooling_register(struct device_node *np,
 	ret = get_idr(&cpufreq_idr, &cpufreq_dev->id);
 	if (ret) {
 		kfree(cpufreq_dev);
-		return ERR_PTR(-EINVAL);
+		return ERR_PTR(cpufreq_dev->id);
 	}
 
 	snprintf(dev_name, sizeof(dev_name), "thermal-cpufreq-%d",