All of lore.kernel.org
 help / color / mirror / Atom feed
From: Heiner Kallweit <hkallweit1@gmail.com>
To: Linus Walleij <linus.walleij@linaro.org>
Cc: linux-gpio@vger.kernel.org
Subject: [PATCH 1/3] gpio: generic: improve error handling in bgpio_map
Date: Wed, 30 Sep 2015 23:50:20 +0200	[thread overview]
Message-ID: <560C591C.2030709@gmail.com> (raw)

If bgpio_map returns NULL then err should always be set.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
 drivers/gpio/gpio-generic.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/gpio/gpio-generic.c b/drivers/gpio/gpio-generic.c
index a3f0753..eefff1a 100644
--- a/drivers/gpio/gpio-generic.c
+++ b/drivers/gpio/gpio-generic.c
@@ -591,8 +591,10 @@ static void __iomem *bgpio_map(struct platform_device *pdev,
 	*err = 0;
 
 	r = platform_get_resource_byname(pdev, IORESOURCE_MEM, name);
-	if (!r)
+	if (!r) {
+		*err = -EINVAL;
 		return NULL;
+	}
 
 	sz = resource_size(r);
 	if (sz != sane_sz) {
@@ -637,8 +639,8 @@ static int bgpio_pdev_probe(struct platform_device *pdev)
 	sz = resource_size(r);
 
 	dat = bgpio_map(pdev, "dat", sz, &err);
-	if (!dat)
-		return err ? err : -EINVAL;
+	if (err)
+		return err;
 
 	set = bgpio_map(pdev, "set", sz, &err);
 	if (err)
-- 
2.6.0


             reply	other threads:[~2015-09-30 21:53 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-30 21:50 Heiner Kallweit [this message]
2015-10-05  7:14 ` [PATCH 1/3] gpio: generic: improve error handling in bgpio_map Linus Walleij

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=560C591C.2030709@gmail.com \
    --to=hkallweit1@gmail.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@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 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.