linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ARM: mvebu: Use common error handling code in mvebu_armada_pm_init()
@ 2017-10-20 13:17 SF Markus Elfring
  2017-10-23  8:57 ` Dan Carpenter
  0 siblings, 1 reply; 3+ messages in thread
From: SF Markus Elfring @ 2017-10-20 13:17 UTC (permalink / raw)
  To: linux-arm-kernel, Andrew Lunn, Gregory Clement, Jason Cooper,
	Russell King, Sebastian Hesselbarth, Thomas Petazzoni
  Cc: LKML, kernel-janitors

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

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] ARM: mvebu: Use common error handling code in mvebu_armada_pm_init()
  2017-10-20 13:17 [PATCH] ARM: mvebu: Use common error handling code in mvebu_armada_pm_init() SF Markus Elfring
@ 2017-10-23  8:57 ` Dan Carpenter
  2017-10-23  9:10   ` SF Markus Elfring
  0 siblings, 1 reply; 3+ messages in thread
From: Dan Carpenter @ 2017-10-23  8:57 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-arm-kernel, Andrew Lunn, Gregory Clement, Jason Cooper,
	Russell King, Sebastian Hesselbarth, Thomas Petazzoni, LKML,
	kernel-janitors

The error handling in mvebu_armada_pm_init() is incomplete and this
patch just smudges it around without fixing anything.

regards,
dan carpenter

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: ARM: mvebu: Use common error handling code in mvebu_armada_pm_init()
  2017-10-23  8:57 ` Dan Carpenter
@ 2017-10-23  9:10   ` SF Markus Elfring
  0 siblings, 0 replies; 3+ messages in thread
From: SF Markus Elfring @ 2017-10-23  9:10 UTC (permalink / raw)
  To: Dan Carpenter, linux-arm-kernel
  Cc: Andrew Lunn, Gregory Clement, Jason Cooper, Russell King,
	Sebastian Hesselbarth, Thomas Petazzoni, LKML, kernel-janitors

> The error handling in mvebu_armada_pm_init() is incomplete

How would you like to extend it?


> and this patch just smudges it around without fixing anything.

How does this kind of feedback fit to information from the section
“7) Centralized exiting of functions” in the document “coding-style.rst”?

Regards,
Markus

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-10-23  9:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-20 13:17 [PATCH] ARM: mvebu: Use common error handling code in mvebu_armada_pm_init() SF Markus Elfring
2017-10-23  8:57 ` Dan Carpenter
2017-10-23  9:10   ` SF Markus Elfring

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