linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] gpio: tb10x: Fix checking return value of devm_ioremap_resource
@ 2013-10-31  2:01 Axel Lin
  2013-10-31  2:03 ` [PATCH 2/2] gpio: tb10x: Convert to use module_platform_driver Axel Lin
  2013-10-31 12:40 ` [PATCH 1/2] gpio: tb10x: Fix checking return value of devm_ioremap_resource Christian Ruppert
  0 siblings, 2 replies; 6+ messages in thread
From: Axel Lin @ 2013-10-31  2:01 UTC (permalink / raw)
  To: Linus Walleij
  Cc: Christian Ruppert, Kumar Gala, Sascha Leuenberger, linux-gpio

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




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

end of thread, other threads:[~2013-11-12 19:36 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-10-31  2:01 [PATCH 1/2] gpio: tb10x: Fix checking return value of devm_ioremap_resource Axel Lin
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

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