All of lore.kernel.org
 help / color / mirror / Atom feed
From: Javier Martinez Canillas <javier.martinez@collabora.co.uk>
To: Linus Walleij <linus.walleij@linaro.org>
Cc: Santosh Shilimkar <santosh.shilimkar@ti.com>,
	Kevin Hilman <khilman@linaro.org>,
	Tony Lindgren <tony@atomide.com>, Paul Walmsley <paul@pwsan.com>,
	Aaro Koskinen <aaro.koskinen@iki.fi>, Nishanth Menon <nm@ti.com>,
	linux-gpio@vger.kernel.org, linux-omap@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	Javier Martinez Canillas <javier.martinez@collabora.co.uk>
Subject: [PATCH 2/5] gpio: omap: check gpiochip_add() return value
Date: Sun,  6 Apr 2014 16:58:14 +0200	[thread overview]
Message-ID: <1396796297-13002-3-git-send-email-javier.martinez@collabora.co.uk> (raw)
In-Reply-To: <1396796297-13002-1-git-send-email-javier.martinez@collabora.co.uk>

The gpiochip_add() function can fail if the chip cannot
be registered so the return value has to be checked and
the error propagated in case it happens.

Signed-off-by: Javier Martinez Canillas <javier.martinez@collabora.co.uk>
---
 drivers/gpio/gpio-omap.c | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
index 3ee9b8d..e717888 100644
--- a/drivers/gpio/gpio-omap.c
+++ b/drivers/gpio/gpio-omap.c
@@ -1081,10 +1081,11 @@ omap_mpuio_alloc_gc(struct gpio_bank *bank, unsigned int irq_start,
 			       IRQ_NOREQUEST | IRQ_NOPROBE, 0);
 }
 
-static void omap_gpio_chip_init(struct gpio_bank *bank)
+static int omap_gpio_chip_init(struct gpio_bank *bank)
 {
 	int j;
 	static int gpio;
+	int ret;
 
 	/*
 	 * REVISIT eventually switch from OMAP-specific gpio structs
@@ -1110,7 +1111,11 @@ static void omap_gpio_chip_init(struct gpio_bank *bank)
 	}
 	bank->chip.ngpio = bank->width;
 
-	gpiochip_add(&bank->chip);
+	ret = gpiochip_add(&bank->chip);
+	if (ret) {
+		dev_err(bank->dev, "Could not register gpio chip\n", ret);
+		return ret;
+	}
 
 	for (j = 0; j < bank->width; j++) {
 		int irq = irq_create_mapping(bank->domain, j);
@@ -1139,6 +1144,7 @@ static int omap_gpio_probe(struct platform_device *pdev)
 	struct resource *res;
 	struct gpio_bank *bank;
 	int irq_base = 0;
+	int ret;
 
 	match = of_match_device(of_match_ptr(omap_gpio_match), dev);
 
@@ -1223,7 +1229,11 @@ static int omap_gpio_probe(struct platform_device *pdev)
 		mpuio_init(bank);
 
 	omap_gpio_mod_init(bank);
-	omap_gpio_chip_init(bank);
+
+	ret = omap_gpio_chip_init(bank);
+	if (ret)
+		return ret;
+
 	omap_gpio_show_rev(bank);
 
 	pm_runtime_put(bank->dev);
-- 
1.9.0


WARNING: multiple messages have this Message-ID (diff)
From: javier.martinez@collabora.co.uk (Javier Martinez Canillas)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 2/5] gpio: omap: check gpiochip_add() return value
Date: Sun,  6 Apr 2014 16:58:14 +0200	[thread overview]
Message-ID: <1396796297-13002-3-git-send-email-javier.martinez@collabora.co.uk> (raw)
In-Reply-To: <1396796297-13002-1-git-send-email-javier.martinez@collabora.co.uk>

The gpiochip_add() function can fail if the chip cannot
be registered so the return value has to be checked and
the error propagated in case it happens.

Signed-off-by: Javier Martinez Canillas <javier.martinez@collabora.co.uk>
---
 drivers/gpio/gpio-omap.c | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
index 3ee9b8d..e717888 100644
--- a/drivers/gpio/gpio-omap.c
+++ b/drivers/gpio/gpio-omap.c
@@ -1081,10 +1081,11 @@ omap_mpuio_alloc_gc(struct gpio_bank *bank, unsigned int irq_start,
 			       IRQ_NOREQUEST | IRQ_NOPROBE, 0);
 }
 
-static void omap_gpio_chip_init(struct gpio_bank *bank)
+static int omap_gpio_chip_init(struct gpio_bank *bank)
 {
 	int j;
 	static int gpio;
+	int ret;
 
 	/*
 	 * REVISIT eventually switch from OMAP-specific gpio structs
@@ -1110,7 +1111,11 @@ static void omap_gpio_chip_init(struct gpio_bank *bank)
 	}
 	bank->chip.ngpio = bank->width;
 
-	gpiochip_add(&bank->chip);
+	ret = gpiochip_add(&bank->chip);
+	if (ret) {
+		dev_err(bank->dev, "Could not register gpio chip\n", ret);
+		return ret;
+	}
 
 	for (j = 0; j < bank->width; j++) {
 		int irq = irq_create_mapping(bank->domain, j);
@@ -1139,6 +1144,7 @@ static int omap_gpio_probe(struct platform_device *pdev)
 	struct resource *res;
 	struct gpio_bank *bank;
 	int irq_base = 0;
+	int ret;
 
 	match = of_match_device(of_match_ptr(omap_gpio_match), dev);
 
@@ -1223,7 +1229,11 @@ static int omap_gpio_probe(struct platform_device *pdev)
 		mpuio_init(bank);
 
 	omap_gpio_mod_init(bank);
-	omap_gpio_chip_init(bank);
+
+	ret = omap_gpio_chip_init(bank);
+	if (ret)
+		return ret;
+
 	omap_gpio_show_rev(bank);
 
 	pm_runtime_put(bank->dev);
-- 
1.9.0

  parent reply	other threads:[~2014-04-06 14:58 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-06 14:58 [PATCH 0/5] GPIO OMAP driver changes for v3.16 Javier Martinez Canillas
2014-04-06 14:58 ` Javier Martinez Canillas
2014-04-06 14:58 ` [PATCH 1/5] gpio: omap: convert to use irq_domain_add_simple() Javier Martinez Canillas
2014-04-06 14:58   ` Javier Martinez Canillas
2014-04-10 17:35   ` Santosh Shilimkar
2014-04-10 17:35     ` Santosh Shilimkar
2014-04-06 14:58 ` Javier Martinez Canillas [this message]
2014-04-06 14:58   ` [PATCH 2/5] gpio: omap: check gpiochip_add() return value Javier Martinez Canillas
2014-04-10 17:36   ` Santosh Shilimkar
2014-04-10 17:36     ` Santosh Shilimkar
2014-04-06 14:58 ` [PATCH 3/5] gpio: omap: add a GPIO_OMAP option instead of using ARCH_OMAP Javier Martinez Canillas
2014-04-06 14:58   ` Javier Martinez Canillas
2014-04-10 17:37   ` Santosh Shilimkar
2014-04-10 17:37     ` Santosh Shilimkar
2014-04-06 14:58 ` [PATCH 4/5] gpio: omap: convert driver to use gpiolib irqchip Javier Martinez Canillas
2014-04-06 14:58   ` Javier Martinez Canillas
2014-04-10 17:39   ` Santosh Shilimkar
2014-04-10 17:39     ` Santosh Shilimkar
2014-04-10 17:45     ` Linus Walleij
2014-04-10 17:45       ` Linus Walleij
2014-04-10 18:58       ` Javier Martinez Canillas
2014-04-10 18:58         ` Javier Martinez Canillas
2014-04-06 14:58 ` [PATCH 5/5] MAINTAINERS: update GPIO OMAP driver entry Javier Martinez Canillas
2014-04-06 14:58   ` Javier Martinez Canillas
2014-04-10 17:29 ` [PATCH 0/5] GPIO OMAP driver changes for v3.16 Linus Walleij
2014-04-10 17:29   ` Linus Walleij
2014-04-10 19:30   ` Aaro Koskinen
2014-04-10 19:30     ` Aaro Koskinen
2014-04-10 20:17     ` Javier Martinez Canillas
2014-04-10 20:17       ` Javier Martinez Canillas
2014-04-10 21:22       ` Aaro Koskinen
2014-04-10 21:22         ` Aaro Koskinen
2014-04-11 15:03         ` Javier Martinez Canillas
2014-04-11 15:03           ` Javier Martinez Canillas
2014-04-22 13:00           ` Linus Walleij
2014-04-22 13:00             ` Linus Walleij
2014-04-23 21:48         ` Javier Martinez Canillas
2014-04-23 21:48           ` Javier Martinez Canillas

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=1396796297-13002-3-git-send-email-javier.martinez@collabora.co.uk \
    --to=javier.martinez@collabora.co.uk \
    --cc=aaro.koskinen@iki.fi \
    --cc=khilman@linaro.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=nm@ti.com \
    --cc=paul@pwsan.com \
    --cc=santosh.shilimkar@ti.com \
    --cc=tony@atomide.com \
    /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.