diff options
author | Fabio Estevam <fabio.estevam@freescale.com> | 2013-07-08 16:14:39 -0400 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2013-07-20 13:38:52 -0400 |
commit | 8cd73e4e3807315115122fd4e3ac7c33007cdf9c (patch) | |
tree | df7fe068b04ef85b0875520543c2e3b65bea9bc0 /drivers/gpio | |
parent | 04777396d8d183f3f3edd3872eb8bf50dd458b82 (diff) |
gpio: gpio-mxc: Use devm functions
By using devm functions we can get a simpler code.
Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
Acked-by: Shawn Guo <shawn.guo@linaro.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/gpio')
-rw-r--r-- | drivers/gpio/gpio-mxc.c | 36 |
1 files changed, 8 insertions, 28 deletions
diff --git a/drivers/gpio/gpio-mxc.c b/drivers/gpio/gpio-mxc.c index 7176743915d3..91f2ac35038a 100644 --- a/drivers/gpio/gpio-mxc.c +++ b/drivers/gpio/gpio-mxc.c | |||
@@ -405,34 +405,19 @@ static int mxc_gpio_probe(struct platform_device *pdev) | |||
405 | 405 | ||
406 | mxc_gpio_get_hw(pdev); | 406 | mxc_gpio_get_hw(pdev); |
407 | 407 | ||
408 | port = kzalloc(sizeof(struct mxc_gpio_port), GFP_KERNEL); | 408 | port = devm_kzalloc(&pdev->dev, sizeof(*port), GFP_KERNEL); |
409 | if (!port) | 409 | if (!port) |
410 | return -ENOMEM; | 410 | return -ENOMEM; |
411 | 411 | ||
412 | iores = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 412 | iores = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
413 | if (!iores) { | 413 | port->base = devm_ioremap_resource(&pdev->dev, iores); |
414 | err = -ENODEV; | 414 | if (IS_ERR(port->base)) |
415 | goto out_kfree; | 415 | return PTR_ERR(port->base); |
416 | } | ||
417 | |||
418 | if (!request_mem_region(iores->start, resource_size(iores), | ||
419 | pdev->name)) { | ||
420 | err = -EBUSY; | ||
421 | goto out_kfree; | ||
422 | } | ||
423 | |||
424 | port->base = ioremap(iores->start, resource_size(iores)); | ||
425 | if (!port->base) { | ||
426 | err = -ENOMEM; | ||
427 | goto out_release_mem; | ||
428 | } | ||
429 | 416 | ||
430 | port->irq_high = platform_get_irq(pdev, 1); | 417 | port->irq_high = platform_get_irq(pdev, 1); |
431 | port->irq = platform_get_irq(pdev, 0); | 418 | port->irq = platform_get_irq(pdev, 0); |
432 | if (port->irq < 0) { | 419 | if (port->irq < 0) |
433 | err = -EINVAL; | 420 | return -EINVAL; |
434 | goto out_iounmap; | ||
435 | } | ||
436 | 421 | ||
437 | /* disable the interrupt and clear the status */ | 422 | /* disable the interrupt and clear the status */ |
438 | writel(0, port->base + GPIO_IMR); | 423 | writel(0, port->base + GPIO_IMR); |
@@ -462,7 +447,7 @@ static int mxc_gpio_probe(struct platform_device *pdev) | |||
462 | port->base + GPIO_DR, NULL, | 447 | port->base + GPIO_DR, NULL, |
463 | port->base + GPIO_GDIR, NULL, 0); | 448 | port->base + GPIO_GDIR, NULL, 0); |
464 | if (err) | 449 | if (err) |
465 | goto out_iounmap; | 450 | goto out_bgio; |
466 | 451 | ||
467 | port->bgc.gc.to_irq = mxc_gpio_to_irq; | 452 | port->bgc.gc.to_irq = mxc_gpio_to_irq; |
468 | port->bgc.gc.base = (pdev->id < 0) ? of_alias_get_id(np, "gpio") * 32 : | 453 | port->bgc.gc.base = (pdev->id < 0) ? of_alias_get_id(np, "gpio") * 32 : |
@@ -498,12 +483,7 @@ out_gpiochip_remove: | |||
498 | WARN_ON(gpiochip_remove(&port->bgc.gc) < 0); | 483 | WARN_ON(gpiochip_remove(&port->bgc.gc) < 0); |
499 | out_bgpio_remove: | 484 | out_bgpio_remove: |
500 | bgpio_remove(&port->bgc); | 485 | bgpio_remove(&port->bgc); |
501 | out_iounmap: | 486 | out_bgio: |
502 | iounmap(port->base); | ||
503 | out_release_mem: | ||
504 | release_mem_region(iores->start, resource_size(iores)); | ||
505 | out_kfree: | ||
506 | kfree(port); | ||
507 | dev_info(&pdev->dev, "%s failed with errno %d\n", __func__, err); | 487 | dev_info(&pdev->dev, "%s failed with errno %d\n", __func__, err); |
508 | return err; | 488 | return err; |
509 | } | 489 | } |