All of lore.kernel.org
 help / color / mirror / Atom feed
From: Viresh Kumar <viresh.kumar@linaro.org>
To: Stephen Boyd <sboyd@codeaurora.org>
Cc: Rafael Wysocki <rjw@rjwysocki.net>,
	nm@ti.com, linaro-kernel@lists.linaro.org,
	linux-pm@vger.kernel.org, khilman@linaro.org,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Len Brown <len.brown@intel.com>,
	open list <linux-kernel@vger.kernel.org>,
	Pavel Machek <pavel@ucw.cz>
Subject: Re: [PATCH 2/6] PM / OPP: restructure _of_init_opp_table_v2()
Date: Tue, 11 Aug 2015 08:03:49 +0530	[thread overview]
Message-ID: <20150811023349.GM5766@linux> (raw)
In-Reply-To: <55C9425B.4060207@codeaurora.org>

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

  parent reply	other threads:[~2015-08-11  2:33 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-10  6:31 [PATCH 0/6] PM / OPP: Add debugfs support Viresh Kumar
2015-08-10  6:31 ` [PATCH 1/6] PM / OPP: reuse of_parse_phandle() Viresh Kumar
2015-08-10  6:31   ` Viresh Kumar
2015-08-11  6:02   ` Stephen Boyd
2015-08-11  6:10     ` Viresh Kumar
2015-08-11  6:23       ` Stephen Boyd
2015-08-11  6:42         ` Viresh Kumar
2015-08-10  6:31 ` [PATCH 2/6] PM / OPP: restructure _of_init_opp_table_v2() Viresh Kumar
2015-08-10  6:31   ` Viresh Kumar
2015-08-10 19:23   ` Stephen Boyd
2015-08-11  0:23     ` Viresh Kumar
2015-08-11  0:31       ` Stephen Boyd
2015-08-11  2:25         ` Viresh Kumar
2015-08-11  6:08           ` Stephen Boyd
2015-08-11  6:57             ` Viresh Kumar
2015-08-11  8:37               ` Viresh Kumar
2015-08-11  2:33         ` Viresh Kumar [this message]
2015-08-11  6:09           ` Stephen Boyd
2015-08-10  6:31 ` [PATCH 3/6] PM / OPP: Prefix exported opp routines with dev_pm_opp_ Viresh Kumar
2015-08-10  6:31   ` Viresh Kumar
2015-08-10 19:24   ` Stephen Boyd
2015-08-10  6:32 ` [PATCH 4/6] PM / OPP: Move opp core to its own directory Viresh Kumar
2015-08-10  6:32   ` Viresh Kumar
2015-08-10 19:51   ` Stephen Boyd
2015-08-11  0:25     ` Viresh Kumar
2015-08-10  6:32 ` [PATCH 5/6] PM / OPP: Move cpu specific code to opp/cpu.c Viresh Kumar
2015-08-10  6:32   ` Viresh Kumar
2015-08-11  6:09   ` Stephen Boyd
2015-08-10  6:32 ` [PATCH 6/6] PM / OPP: Add debugfs support Viresh Kumar
2015-08-10  6:32   ` Viresh Kumar
2015-08-10 19:50   ` Stephen Boyd
2015-08-11  6:35     ` Viresh Kumar
2015-08-11  6:37     ` Viresh Kumar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150811023349.GM5766@linux \
    --to=viresh.kumar@linaro.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=khilman@linaro.org \
    --cc=len.brown@intel.com \
    --cc=linaro-kernel@lists.linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=nm@ti.com \
    --cc=pavel@ucw.cz \
    --cc=rjw@rjwysocki.net \
    --cc=sboyd@codeaurora.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.