diff mbox

[2/6] PM / OPP: restructure _of_init_opp_table_v2()

Message ID 20150811065738.GE5147@linux
State New
Headers show

Commit Message

Viresh Kumar Aug. 11, 2015, 6:57 a.m. UTC
On 10-08-15, 23:08, Stephen Boyd wrote:
> On 08/11, Viresh Kumar wrote:
> > On 10-08-15, 17:31, Stephen Boyd wrote:
> > > So ret is 0. I thought it was an error path, but I guess this is a
> > > warning path and we return 0 still?
> > 
> > Urg ..
> 
> Oh I see this is an existing problem... Same problem goes for the
> count check. It may be better to fix those two cases first and
> then do this cleanup. But I don't mind either way.

-------------------------8<-------------------------
Message-Id: <b2d2d842165ec1748a56ecc03b85bd89321a644b.1439276231.git.viresh.kumar@linaro.org>
From: Viresh Kumar <viresh.kumar@linaro.org>
Date: Tue, 11 Aug 2015 12:22:07 +0530
Subject: [PATCH] PM / OPP: Return proper errors on failure

We are returning 0 by mistake, fix it.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 drivers/base/power/opp.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

--
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

Comments

Viresh Kumar Aug. 11, 2015, 8:37 a.m. UTC | #1
On 11-08-15, 12:27, Viresh Kumar wrote:
> diff --git a/drivers/base/power/opp.c b/drivers/base/power/opp.c
> index 1daaa1a418a2..be3356a3a452 100644
> --- a/drivers/base/power/opp.c
> +++ b/drivers/base/power/opp.c
> @@ -1292,14 +1292,18 @@ static int _of_init_opp_table_v2(struct device *dev,
>  	}
>  
>  	/* There should be one of more OPP defined */
> -	if (WARN_ON(!count))
> +	if (WARN_ON(!count)) {
> +		ret = -ENOENT;
>  		goto out;
> +	}
>  
>  	if (!ret) {
>  		if (!dev_opp) {
>  			dev_opp = _find_device_opp(dev);
> -			if (WARN_ON(!dev_opp))
> +			if (WARN_ON(!dev_opp)) {

Dan also reported that !dev_opp isn't enough as we need to use IS_ERR
here.

We have got enough updates here, let me resend the series again to get
more reviews on proper patches.
diff mbox

Patch

diff --git a/drivers/base/power/opp.c b/drivers/base/power/opp.c
index 1daaa1a418a2..be3356a3a452 100644
--- a/drivers/base/power/opp.c
+++ b/drivers/base/power/opp.c
@@ -1292,14 +1292,18 @@  static int _of_init_opp_table_v2(struct device *dev,
 	}
 
 	/* There should be one of more OPP defined */
-	if (WARN_ON(!count))
+	if (WARN_ON(!count)) {
+		ret = -ENOENT;
 		goto out;
+	}
 
 	if (!ret) {
 		if (!dev_opp) {
 			dev_opp = _find_device_opp(dev);
-			if (WARN_ON(!dev_opp))
+			if (WARN_ON(!dev_opp)) {
+				ret = -ENOENT;
 				goto out;
+			}
 		}
 
 		dev_opp->np = opp_np;