All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] gpio: langwell: use devm_* helpers to simplify probe
@ 2012-04-05  9:15 Mika Westerberg
  2012-04-05  9:15 ` [PATCH 2/3] gpio: langwell: allocate IRQ descriptors dynamically for SPARSE_IRQ Mika Westerberg
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Mika Westerberg @ 2012-04-05  9:15 UTC (permalink / raw)
  To: linux-kernel; +Cc: grant.likely, linus.walleij, Mika Westerberg

Use devm_* helper functions where possible to make the error handling in
the probe function simpler.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
---
 drivers/gpio/gpio-langwell.c |   18 +++++++-----------
 1 files changed, 7 insertions(+), 11 deletions(-)

diff --git a/drivers/gpio/gpio-langwell.c b/drivers/gpio/gpio-langwell.c
index 00692e8..0bea41b 100644
--- a/drivers/gpio/gpio-langwell.c
+++ b/drivers/gpio/gpio-langwell.c
@@ -309,7 +309,7 @@ static int __devinit lnw_gpio_probe(struct pci_dev *pdev,
 
 	retval = pci_enable_device(pdev);
 	if (retval)
-		goto done;
+		return retval;
 
 	retval = pci_request_regions(pdev, "langwell_gpio");
 	if (retval) {
@@ -331,18 +331,18 @@ static int __devinit lnw_gpio_probe(struct pci_dev *pdev,
 	/* get the register base from bar0 */
 	start = pci_resource_start(pdev, 0);
 	len = pci_resource_len(pdev, 0);
-	base = ioremap_nocache(start, len);
+	base = devm_ioremap_nocache(&pdev->dev, start, len);
 	if (!base) {
 		dev_err(&pdev->dev, "error mapping bar0\n");
 		retval = -EFAULT;
 		goto err3;
 	}
 
-	lnw = kzalloc(sizeof(struct lnw_gpio), GFP_KERNEL);
+	lnw = devm_kzalloc(&pdev->dev, sizeof(struct lnw_gpio), GFP_KERNEL);
 	if (!lnw) {
 		dev_err(&pdev->dev, "can't allocate langwell_gpio chip data\n");
 		retval = -ENOMEM;
-		goto err4;
+		goto err3;
 	}
 	lnw->reg_base = base;
 	lnw->irq_base = irq_base;
@@ -361,7 +361,7 @@ static int __devinit lnw_gpio_probe(struct pci_dev *pdev,
 	retval = gpiochip_add(&lnw->chip);
 	if (retval) {
 		dev_err(&pdev->dev, "langwell gpiochip_add error %d\n", retval);
-		goto err5;
+		goto err3;
 	}
 	irq_set_handler_data(pdev->irq, lnw);
 	irq_set_chained_handler(pdev->irq, lnw_irq_handler);
@@ -376,16 +376,12 @@ static int __devinit lnw_gpio_probe(struct pci_dev *pdev,
 	pm_runtime_put_noidle(&pdev->dev);
 	pm_runtime_allow(&pdev->dev);
 
-	goto done;
-err5:
-	kfree(lnw);
-err4:
-	iounmap(base);
+	return 0;
+
 err3:
 	pci_release_regions(pdev);
 err2:
 	pci_disable_device(pdev);
-done:
 	return retval;
 }
 
-- 
1.7.9.1


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

end of thread, other threads:[~2012-04-24 10:12 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-04-05  9:15 [PATCH 1/3] gpio: langwell: use devm_* helpers to simplify probe Mika Westerberg
2012-04-05  9:15 ` [PATCH 2/3] gpio: langwell: allocate IRQ descriptors dynamically for SPARSE_IRQ Mika Westerberg
2012-04-06  4:34   ` Grant Likely
2012-04-10  7:18     ` Mika Westerberg
2012-04-24 10:13     ` Mika Westerberg
2012-04-05  9:15 ` [PATCH 3/3] gpio: langwell: clear IRQ edge detect registers at init Mika Westerberg
2012-04-06  4:39   ` Grant Likely
2012-04-06  4:26 ` [PATCH 1/3] gpio: langwell: use devm_* helpers to simplify probe Grant Likely

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.