Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1204702

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

From Viresh Kumar <viresh.kumar@linaro.org>
Newsgroups linux.kernel
Subject Re: [PATCH 2/6] PM / OPP: restructure _of_init_opp_table_v2()
Date 2015-08-11 04:40 +0200
Message-ID <pW7DP-5l-5@gated-at.bofh.it> (permalink)
References <pVOUy-6bs-7@gated-at.bofh.it> <pVOUy-6bs-19@gated-at.bofh.it> <pW0VI-7eq-9@gated-at.bofh.it> <pW5C3-5yL-11@gated-at.bofh.it> <pW5LI-5JT-1@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On 10-08-15, 17:31, Stephen Boyd wrote:
> I am not insisting anything. But another patch to get rid of the
> goto sounds fine.

The separate patch to kill goto.

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

Message-Id: <9f9b9ea6ea3685d5f71c132e7efb18917253961f.1439260355.git.viresh.kumar@linaro.org>
From: Viresh Kumar <viresh.kumar@linaro.org>
Date: Tue, 11 Aug 2015 08:01:01 +0530
Subject: [PATCH] PM / OPP: Remove unnecessary goto statements

The code simply returns after jumping to the out label and doesn't free
any resources, etc.

Kill the unnecessary goto statements.

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

diff --git a/drivers/base/power/opp.c b/drivers/base/power/opp.c
index f42e098b71fe..220e8d77e2c4 100644
--- a/drivers/base/power/opp.c
+++ b/drivers/base/power/opp.c
@@ -1269,14 +1269,14 @@ static int _of_init_opp_table_v2(struct device *dev,
 {
 	struct device_node *np;
 	struct device_opp *dev_opp;
-	int ret = 0, count = 0;
+	int ret, count = 0;
 
 	dev_opp = _managed_opp(opp_np);
 	if (dev_opp) {
 		/* OPPs are already managed */
 		if (!_add_list_dev(dev, dev_opp))
-			ret = -ENOMEM;
-		goto out;
+			return -ENOMEM;
+		return 0;
 	}
 
 	/* We have opp-list node now, iterate over it and add OPPs */
@@ -1287,31 +1287,24 @@ static int _of_init_opp_table_v2(struct device *dev,
 		if (ret) {
 			dev_err(dev, "%s: Failed to add OPP, %d\n", __func__,
 				ret);
-			break;
+			of_free_opp_table(dev);
+			return ret;
 		}
 	}
 
 	/* There should be one of more OPP defined */
 	if (WARN_ON(!count))
-		goto out;
-
-	if (ret) {
-		of_free_opp_table(dev);
-		goto out;
-	}
+		return -ENOENT;
 
 	dev_opp = _find_device_opp(dev);
-	if (WARN_ON(!dev_opp)) {
-		ret = -EINVAL;
-		goto out;
-	}
+	if (WARN_ON(!dev_opp))
+		return -EINVAL;
 
 	dev_opp->np = opp_np;
 	dev_opp->shared_opp = of_property_read_bool(opp_np,
 			"opp-shared");
 
-out:
-	return ret;
+	return 0;
 }
 
 /* Initializes OPP tables based on old-deprecated bindings */
--
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/

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 2/6] PM / OPP: restructure _of_init_opp_table_v2() Viresh Kumar <viresh.kumar@linaro.org> - 2015-08-10 08:40 +0200
  Re: [PATCH 2/6] PM / OPP: restructure _of_init_opp_table_v2() Stephen Boyd <sboyd@codeaurora.org> - 2015-08-10 21:30 +0200
    Re: [PATCH 2/6] PM / OPP: restructure _of_init_opp_table_v2() Viresh Kumar <viresh.kumar@linaro.org> - 2015-08-11 02:30 +0200
      Re: [PATCH 2/6] PM / OPP: restructure _of_init_opp_table_v2() Stephen Boyd <sboyd@codeaurora.org> - 2015-08-11 02:40 +0200
        Re: [PATCH 2/6] PM / OPP: restructure _of_init_opp_table_v2() Viresh Kumar <viresh.kumar@linaro.org> - 2015-08-11 04:30 +0200
          Re: [PATCH 2/6] PM / OPP: restructure _of_init_opp_table_v2() Stephen Boyd <sboyd@codeaurora.org> - 2015-08-11 08:10 +0200
            Re: [PATCH 2/6] PM / OPP: restructure _of_init_opp_table_v2() Viresh Kumar <viresh.kumar@linaro.org> - 2015-08-11 09:00 +0200
              Re: [PATCH 2/6] PM / OPP: restructure _of_init_opp_table_v2() Viresh Kumar <viresh.kumar@linaro.org> - 2015-08-11 10:40 +0200
        Re: [PATCH 2/6] PM / OPP: restructure _of_init_opp_table_v2() Viresh Kumar <viresh.kumar@linaro.org> - 2015-08-11 04:40 +0200
          Re: [PATCH 2/6] PM / OPP: restructure _of_init_opp_table_v2() Stephen Boyd <sboyd@codeaurora.org> - 2015-08-11 08:10 +0200

csiph-web