Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Enrico Weigelt, metux IT consult and committed by
Linus Walleij
c7d0ca24 52728565

+5 -14
+5 -14
drivers/gpio/gpio-vr41xx.c
··· 467 467 468 468 static int giu_probe(struct platform_device *pdev) 469 469 { 470 - struct resource *res; 471 470 unsigned int trigger, i, pin; 472 471 struct irq_chip *chip; 473 - int irq, ret; 472 + int irq; 474 473 475 474 switch (pdev->id) { 476 475 case GPIO_50PINS_PULLUPDOWN: ··· 488 489 return -ENODEV; 489 490 } 490 491 491 - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 492 - if (!res) 493 - return -EBUSY; 494 - 495 - giu_base = ioremap(res->start, resource_size(res)); 496 - if (!giu_base) 497 - return -ENOMEM; 492 + giu_base = devm_platform_ioremap_resource(pdev, 0); 493 + if (IS_ERR(giu_base)) 494 + return PTR_ERR(giu_base); 498 495 499 496 vr41xx_gpio_chip.parent = &pdev->dev; 500 497 501 - ret = gpiochip_add_data(&vr41xx_gpio_chip, NULL); 502 - if (!ret) { 503 - iounmap(giu_base); 498 + if (gpiochip_add_data(&vr41xx_gpio_chip, NULL)) 504 499 return -ENODEV; 505 - } 506 500 507 501 giu_write(GIUINTENL, 0); 508 502 giu_write(GIUINTENH, 0); ··· 526 534 static int giu_remove(struct platform_device *pdev) 527 535 { 528 536 if (giu_base) { 529 - iounmap(giu_base); 530 537 giu_base = NULL; 531 538 } 532 539