linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: SF Markus Elfring <elfring@users.sourceforge.net>
To: linux-gpio@vger.kernel.org,
	Andrew Bresticker <abrestic@chromium.org>,
	Damien Horsley <Damien.Horsley@imgtec.com>,
	Ezequiel Garcia <ezequiel.garcia@imgtec.com>,
	Govindraj Raja <govindraj.raja@imgtec.com>,
	Kevin Cernekee <cernekee@chromium.org>,
	Linus Walleij <linus.walleij@linaro.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
	kernel-janitors <kernel-janitors@vger.kernel.org>,
	James Hartley <james.hartley@imgtec.com>,
	James Hogan <james.hogan@imgtec.com>
Subject: [PATCH] pinctrl: pistachio: Use common error handling code in pistachio_gpio_register()
Date: Mon, 30 Oct 2017 18:51:19 +0100	[thread overview]
Message-ID: <0b8eced6-c4d9-6b0b-ac23-de764622e91c@users.sourceforge.net> (raw)

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 30 Oct 2017 18:40:10 +0100

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>
---
 drivers/pinctrl/pinctrl-pistachio.c | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/drivers/pinctrl/pinctrl-pistachio.c b/drivers/pinctrl/pinctrl-pistachio.c
index 55375b1b3cc8..b314eb61bf35 100644
--- a/drivers/pinctrl/pinctrl-pistachio.c
+++ b/drivers/pinctrl/pinctrl-pistachio.c
@@ -1362,21 +1362,21 @@ static int pistachio_gpio_register(struct pistachio_pinctrl *pctl)
 		if (!child) {
 			dev_err(pctl->dev, "No node for bank %u\n", i);
 			ret = -ENODEV;
-			goto err;
+			goto remove_chips;
 		}
 
 		if (!of_find_property(child, "gpio-controller", NULL)) {
 			dev_err(pctl->dev,
 				"No gpio-controller property for bank %u\n", i);
 			ret = -ENODEV;
-			goto err;
+			goto remove_chips;
 		}
 
 		irq = irq_of_parse_and_map(child, 0);
 		if (irq < 0) {
 			dev_err(pctl->dev, "No IRQ for bank %u: %d\n", i, irq);
 			ret = irq;
-			goto err;
+			goto remove_chips;
 		}
 
 		bank = &pctl->gpio_banks[i];
@@ -1389,7 +1389,7 @@ static int pistachio_gpio_register(struct pistachio_pinctrl *pctl)
 		if (ret < 0) {
 			dev_err(pctl->dev, "Failed to add GPIO chip %u: %d\n",
 				i, ret);
-			goto err;
+			goto remove_chips;
 		}
 
 		ret = gpiochip_irqchip_add(&bank->gpio_chip, &bank->irq_chip,
@@ -1397,8 +1397,7 @@ static int pistachio_gpio_register(struct pistachio_pinctrl *pctl)
 		if (ret < 0) {
 			dev_err(pctl->dev, "Failed to add IRQ chip %u: %d\n",
 				i, ret);
-			gpiochip_remove(&bank->gpio_chip);
-			goto err;
+			goto remove_chip;
 		}
 		gpiochip_set_chained_irqchip(&bank->gpio_chip, &bank->irq_chip,
 					     irq, pistachio_gpio_irq_handler);
@@ -1409,13 +1408,15 @@ static int pistachio_gpio_register(struct pistachio_pinctrl *pctl)
 		if (ret < 0) {
 			dev_err(pctl->dev, "Failed to add GPIO range %u: %d\n",
 				i, ret);
-			gpiochip_remove(&bank->gpio_chip);
-			goto err;
+			goto remove_chip;
 		}
 	}
 
 	return 0;
-err:
+
+remove_chip:
+	gpiochip_remove(&bank->gpio_chip);
+remove_chips:
 	for (; i > 0; i--) {
 		bank = &pctl->gpio_banks[i - 1];
 		gpiochip_remove(&bank->gpio_chip);
-- 
2.14.3


             reply	other threads:[~2017-10-30 17:51 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-30 17:51 SF Markus Elfring [this message]
2017-10-31 16:13 ` [PATCH] pinctrl: pistachio: Use common error handling code in pistachio_gpio_register() Andrew Bresticker
2017-11-01 10:18 ` Dan Carpenter

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=0b8eced6-c4d9-6b0b-ac23-de764622e91c@users.sourceforge.net \
    --to=elfring@users.sourceforge.net \
    --cc=Damien.Horsley@imgtec.com \
    --cc=abrestic@chromium.org \
    --cc=cernekee@chromium.org \
    --cc=ezequiel.garcia@imgtec.com \
    --cc=govindraj.raja@imgtec.com \
    --cc=james.hartley@imgtec.com \
    --cc=james.hogan@imgtec.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.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).