summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorEnrico Weigelt, metux IT consult <info@metux.net>2019-06-17 12:49:20 -0400
committerLinus Walleij <linus.walleij@linaro.org>2019-06-27 10:56:51 -0400
commitc7d0ca24fd978ac047db67dd961788e62c0e8ba2 (patch)
treee315291ca177745ec98616b426b3db60d7cc352e /drivers
parent5272856533776260d997c8280dad69b1eac40994 (diff)
gpio: vr41xx: Use devm_platform_ioremap_resource()
Use the new helper that wraps the calls to platform_get_resource() and devm_ioremap_resource() together. this driver deserves a bit more cleanup, to get rid of the global variable giu_base, which makes it single-instance-only. Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/gpio/gpio-vr41xx.c19
1 files changed, 5 insertions, 14 deletions
diff --git a/drivers/gpio/gpio-vr41xx.c b/drivers/gpio/gpio-vr41xx.c
index b13a49c89cc1..98cd715ccc33 100644
--- a/drivers/gpio/gpio-vr41xx.c
+++ b/drivers/gpio/gpio-vr41xx.c
@@ -467,10 +467,9 @@ static struct gpio_chip vr41xx_gpio_chip = {
467 467
468static int giu_probe(struct platform_device *pdev) 468static int giu_probe(struct platform_device *pdev)
469{ 469{
470 struct resource *res;
471 unsigned int trigger, i, pin; 470 unsigned int trigger, i, pin;
472 struct irq_chip *chip; 471 struct irq_chip *chip;
473 int irq, ret; 472 int irq;
474 473
475 switch (pdev->id) { 474 switch (pdev->id) {
476 case GPIO_50PINS_PULLUPDOWN: 475 case GPIO_50PINS_PULLUPDOWN:
@@ -489,21 +488,14 @@ static int giu_probe(struct platform_device *pdev)
489 return -ENODEV; 488 return -ENODEV;
490 } 489 }
491 490
492 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 491 giu_base = devm_platform_ioremap_resource(pdev, 0);
493 if (!res) 492 if (IS_ERR(giu_base))
494 return -EBUSY; 493 return PTR_ERR(giu_base);
495
496 giu_base = ioremap(res->start, resource_size(res));
497 if (!giu_base)
498 return -ENOMEM;
499 494
500 vr41xx_gpio_chip.parent = &pdev->dev; 495 vr41xx_gpio_chip.parent = &pdev->dev;
501 496
502 ret = gpiochip_add_data(&vr41xx_gpio_chip, NULL); 497 if (gpiochip_add_data(&vr41xx_gpio_chip, NULL))
503 if (!ret) {
504 iounmap(giu_base);
505 return -ENODEV; 498 return -ENODEV;
506 }
507 499
508 giu_write(GIUINTENL, 0); 500 giu_write(GIUINTENL, 0);
509 giu_write(GIUINTENH, 0); 501 giu_write(GIUINTENH, 0);
@@ -534,7 +526,6 @@ static int giu_probe(struct platform_device *pdev)
534static int giu_remove(struct platform_device *pdev) 526static int giu_remove(struct platform_device *pdev)
535{ 527{
536 if (giu_base) { 528 if (giu_base) {
537 iounmap(giu_base);
538 giu_base = NULL; 529 giu_base = NULL;
539 } 530 }
540 531