linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Axel Lin <axel.lin@ingics.com>
To: Linus Walleij <linus.walleij@linaro.org>
Cc: Christian Ruppert <christian.ruppert@abilis.com>,
	Kumar Gala <galak@codeaurora.org>,
	Sascha Leuenberger <sascha.leuenberger@abilis.com>,
	linux-gpio@vger.kernel.org
Subject: [PATCH 1/2] gpio: tb10x: Fix checking return value of devm_ioremap_resource
Date: Thu, 31 Oct 2013 10:01:45 +0800	[thread overview]
Message-ID: <1383184905.13635.1.camel@phoenix> (raw)

Also move platform_get_resource() call close to devm_ioremap_resource().
The implementation of devm_ioremap_resource() will also check mem parameter
and emit proper error.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
---
 drivers/gpio/gpio-tb10x.c | 14 +++-----------
 1 file changed, 3 insertions(+), 11 deletions(-)

diff --git a/drivers/gpio/gpio-tb10x.c b/drivers/gpio/gpio-tb10x.c
index 833d0f4..45bfed1 100644
--- a/drivers/gpio/gpio-tb10x.c
+++ b/drivers/gpio/gpio-tb10x.c
@@ -194,23 +194,16 @@ static int tb10x_gpio_probe(struct platform_device *pdev)
 	if (of_property_read_u32(dn, "abilis,ngpio", &ngpio))
 		return -EINVAL;
 
-	mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!mem) {
-		dev_err(&pdev->dev, "No memory resource defined.\n");
-		return -EINVAL;
-	}
-
 	tb10x_gpio = devm_kzalloc(&pdev->dev, sizeof(*tb10x_gpio), GFP_KERNEL);
 	if (tb10x_gpio == NULL)
 		return -ENOMEM;
 
 	spin_lock_init(&tb10x_gpio->spinlock);
 
+	mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	tb10x_gpio->base = devm_ioremap_resource(&pdev->dev, mem);
-	if (!tb10x_gpio->base) {
-		dev_err(&pdev->dev, "Could not remap reg space.\n");
-		goto fail_ioremap;
-	}
+	if (IS_ERR(tb10x_gpio->base))
+		return PTR_ERR(tb10x_gpio->base);
 
 	tb10x_gpio->gc.label		= of_node_full_name(dn);
 	tb10x_gpio->gc.dev		= &pdev->dev;
@@ -285,7 +278,6 @@ fail_request_irq:
 fail_get_irq:
 	gpiochip_remove(&tb10x_gpio->gc);
 fail_gpiochip_registration:
-fail_ioremap:
 	return ret;
 }
 
-- 
1.8.1.2




             reply	other threads:[~2013-10-31  2:01 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-31  2:01 Axel Lin [this message]
2013-10-31  2:03 ` [PATCH 2/2] gpio: tb10x: Convert to use module_platform_driver Axel Lin
2013-10-31 12:41   ` Christian Ruppert
2013-11-12 19:36   ` Linus Walleij
2013-10-31 12:40 ` [PATCH 1/2] gpio: tb10x: Fix checking return value of devm_ioremap_resource Christian Ruppert
2013-11-01 13:28   ` Axel Lin

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=1383184905.13635.1.camel@phoenix \
    --to=axel.lin@ingics.com \
    --cc=christian.ruppert@abilis.com \
    --cc=galak@codeaurora.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=sascha.leuenberger@abilis.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 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).