aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpio/gpio-langwell.c
diff options
context:
space:
mode:
authorMika Westerberg <mika.westerberg@linux.intel.com>2012-04-05 05:15:15 -0400
committerGrant Likely <grant.likely@secretlab.ca>2012-04-06 00:24:46 -0400
commit8302c7413814e26959f69d36a0dcc1f945573bc9 (patch)
treeba9dfe6a8fea509d0b7c20c18c0a1fc8ad971e3b /drivers/gpio/gpio-langwell.c
parentfc3a1f04f5040255cbc086c419e4237f29f89f88 (diff)
gpio/langwell: use devm_* helpers to simplify probe
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> Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Diffstat (limited to 'drivers/gpio/gpio-langwell.c')
-rw-r--r--drivers/gpio/gpio-langwell.c18
1 files changed, 7 insertions, 11 deletions
diff --git a/drivers/gpio/gpio-langwell.c b/drivers/gpio/gpio-langwell.c
index 00692e89ef87..0bea41b8a226 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,
309 309
310 retval = pci_enable_device(pdev); 310 retval = pci_enable_device(pdev);
311 if (retval) 311 if (retval)
312 goto done; 312 return retval;
313 313
314 retval = pci_request_regions(pdev, "langwell_gpio"); 314 retval = pci_request_regions(pdev, "langwell_gpio");
315 if (retval) { 315 if (retval) {
@@ -331,18 +331,18 @@ static int __devinit lnw_gpio_probe(struct pci_dev *pdev,
331 /* get the register base from bar0 */ 331 /* get the register base from bar0 */
332 start = pci_resource_start(pdev, 0); 332 start = pci_resource_start(pdev, 0);
333 len = pci_resource_len(pdev, 0); 333 len = pci_resource_len(pdev, 0);
334 base = ioremap_nocache(start, len); 334 base = devm_ioremap_nocache(&pdev->dev, start, len);
335 if (!base) { 335 if (!base) {
336 dev_err(&pdev->dev, "error mapping bar0\n"); 336 dev_err(&pdev->dev, "error mapping bar0\n");
337 retval = -EFAULT; 337 retval = -EFAULT;
338 goto err3; 338 goto err3;
339 } 339 }
340 340
341 lnw = kzalloc(sizeof(struct lnw_gpio), GFP_KERNEL); 341 lnw = devm_kzalloc(&pdev->dev, sizeof(struct lnw_gpio), GFP_KERNEL);
342 if (!lnw) { 342 if (!lnw) {
343 dev_err(&pdev->dev, "can't allocate langwell_gpio chip data\n"); 343 dev_err(&pdev->dev, "can't allocate langwell_gpio chip data\n");
344 retval = -ENOMEM; 344 retval = -ENOMEM;
345 goto err4; 345 goto err3;
346 } 346 }
347 lnw->reg_base = base; 347 lnw->reg_base = base;
348 lnw->irq_base = irq_base; 348 lnw->irq_base = irq_base;
@@ -361,7 +361,7 @@ static int __devinit lnw_gpio_probe(struct pci_dev *pdev,
361 retval = gpiochip_add(&lnw->chip); 361 retval = gpiochip_add(&lnw->chip);
362 if (retval) { 362 if (retval) {
363 dev_err(&pdev->dev, "langwell gpiochip_add error %d\n", retval); 363 dev_err(&pdev->dev, "langwell gpiochip_add error %d\n", retval);
364 goto err5; 364 goto err3;
365 } 365 }
366 irq_set_handler_data(pdev->irq, lnw); 366 irq_set_handler_data(pdev->irq, lnw);
367 irq_set_chained_handler(pdev->irq, lnw_irq_handler); 367 irq_set_chained_handler(pdev->irq, lnw_irq_handler);
@@ -376,16 +376,12 @@ static int __devinit lnw_gpio_probe(struct pci_dev *pdev,
376 pm_runtime_put_noidle(&pdev->dev); 376 pm_runtime_put_noidle(&pdev->dev);
377 pm_runtime_allow(&pdev->dev); 377 pm_runtime_allow(&pdev->dev);
378 378
379 goto done; 379 return 0;
380err5: 380
381 kfree(lnw);
382err4:
383 iounmap(base);
384err3: 381err3:
385 pci_release_regions(pdev); 382 pci_release_regions(pdev);
386err2: 383err2:
387 pci_disable_device(pdev); 384 pci_disable_device(pdev);
388done:
389 return retval; 385 return retval;
390} 386}
391 387