diff mbox

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

Message ID 20150811022546.GL5766@linux
State New
Headers show

Commit Message

Viresh Kumar Aug. 11, 2015, 2:25 a.m. UTC
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 ..

-------------------------8<-------------------------

Message-Id: <d0e8a9cd6b0fb38fa946cb6274f258d7aa66c00e.1439259818.git.viresh.kumar@linaro.org>
From: Viresh Kumar <viresh.kumar@linaro.org>
Date: Tue, 4 Aug 2015 11:57:36 +0530
Subject: [PATCH] PM / OPP: restructure _of_init_opp_table_v2()

'dev_opp' will always be NULL in _of_init_opp_table_v2() after creating
OPPs for a device. There is no point comparing it against NULL there.

Restructure code a bit to make it more efficient.

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

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/
diff mbox

Patch

diff --git a/drivers/base/power/opp.c b/drivers/base/power/opp.c
index 1daaa1a418a2..f42e098b71fe 100644
--- a/drivers/base/power/opp.c
+++ b/drivers/base/power/opp.c
@@ -1295,20 +1295,21 @@  static int _of_init_opp_table_v2(struct device *dev,
 	if (WARN_ON(!count))
 		goto out;
 
-	if (!ret) {
-		if (!dev_opp) {
-			dev_opp = _find_device_opp(dev);
-			if (WARN_ON(!dev_opp))
-				goto out;
-		}
-
-		dev_opp->np = opp_np;
-		dev_opp->shared_opp = of_property_read_bool(opp_np,
-							    "opp-shared");
-	} else {
+	if (ret) {
 		of_free_opp_table(dev);
+		goto out;
 	}
 
+	dev_opp = _find_device_opp(dev);
+	if (WARN_ON(!dev_opp)) {
+		ret = -EINVAL;
+		goto out;
+	}
+
+	dev_opp->np = opp_np;
+	dev_opp->shared_opp = of_property_read_bool(opp_np,
+			"opp-shared");
+
 out:
 	return ret;
 }