linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: elfring@users.sourceforge.net (SF Markus Elfring)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] ARM: mvebu: Use common error handling code in mvebu_armada_pm_init()
Date: Fri, 20 Oct 2017 15:17:51 +0200	[thread overview]
Message-ID: <1c378b21-f10a-3a3a-fcee-8f0c0214a8fe@users.sourceforge.net> (raw)

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 20 Oct 2017 14:50:47 +0200

Adjust jump targets so that a bit of exception handling can be better
reused at the end of this function.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 arch/arm/mach-mvebu/pm-board.c | 35 ++++++++++++++++-------------------
 1 file changed, 16 insertions(+), 19 deletions(-)

diff --git a/arch/arm/mach-mvebu/pm-board.c b/arch/arm/mach-mvebu/pm-board.c
index db17121d7d63..bef248c76951 100644
--- a/arch/arm/mach-mvebu/pm-board.c
+++ b/arch/arm/mach-mvebu/pm-board.c
@@ -81,6 +81,7 @@ static int __init mvebu_armada_pm_init(void)
 	struct device_node *np;
 	struct device_node *gpio_ctrl_np;
 	int ret = 0, i;
+	char *name;
 
 	if (!of_machine_is_compatible("marvell,axp-gp"))
 		return -ENODEV;
@@ -90,41 +91,32 @@ static int __init mvebu_armada_pm_init(void)
 		return -ENODEV;
 
 	for (i = 0; i < ARMADA_PIC_NR_GPIOS; i++) {
-		char *name;
 		struct of_phandle_args args;
 
 		pic_gpios[i] = of_get_named_gpio(np, "ctrl-gpios", i);
 		if (pic_gpios[i] < 0) {
 			ret = -ENODEV;
-			goto out;
+			goto put_node;
 		}
 
 		name = kasprintf(GFP_KERNEL, "pic-pin%d", i);
 		if (!name) {
 			ret = -ENOMEM;
-			goto out;
+			goto put_node;
 		}
 
 		ret = gpio_request(pic_gpios[i], name);
-		if (ret < 0) {
-			kfree(name);
-			goto out;
-		}
+		if (ret < 0)
+			goto free_name;
 
 		ret = gpio_direction_output(pic_gpios[i], 0);
-		if (ret < 0) {
-			gpio_free(pic_gpios[i]);
-			kfree(name);
-			goto out;
-		}
+		if (ret < 0)
+			goto free_gpio;
 
 		ret = of_parse_phandle_with_fixed_args(np, "ctrl-gpios", 2,
 						       i, &args);
-		if (ret < 0) {
-			gpio_free(pic_gpios[i]);
-			kfree(name);
-			goto out;
-		}
+		if (ret < 0)
+			goto free_gpio;
 
 		gpio_ctrl_np = args.np;
 		pic_raw_gpios[i] = args.args[0];
@@ -135,10 +127,15 @@ static int __init mvebu_armada_pm_init(void)
 		return -ENOMEM;
 
 	mvebu_pm_suspend_init(mvebu_armada_pm_enter);
-
-out:
+put_node:
 	of_node_put(np);
 	return ret;
+
+free_gpio:
+	gpio_free(pic_gpios[i]);
+free_name:
+	kfree(name);
+	goto put_node;
 }
 
 /*
-- 
2.14.2

             reply	other threads:[~2017-10-20 13:17 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-20 13:17 SF Markus Elfring [this message]
2017-10-23  8:57 ` [PATCH] ARM: mvebu: Use common error handling code in mvebu_armada_pm_init() Dan Carpenter
2017-10-23  9:10   ` SF Markus Elfring

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=1c378b21-f10a-3a3a-fcee-8f0c0214a8fe@users.sourceforge.net \
    --to=elfring@users.sourceforge.net \
    --cc=linux-arm-kernel@lists.infradead.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).