Commit c7d0ca24 authored by Enrico Weigelt, metux IT consult's avatar Enrico Weigelt, metux IT consult Committed by Linus Walleij

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: default avatarEnrico Weigelt, metux IT consult <info@metux.net>
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent 52728565
...@@ -467,10 +467,9 @@ static struct gpio_chip vr41xx_gpio_chip = { ...@@ -467,10 +467,9 @@ static struct gpio_chip vr41xx_gpio_chip = {
static int giu_probe(struct platform_device *pdev) static int giu_probe(struct platform_device *pdev)
{ {
struct resource *res;
unsigned int trigger, i, pin; unsigned int trigger, i, pin;
struct irq_chip *chip; struct irq_chip *chip;
int irq, ret; int irq;
switch (pdev->id) { switch (pdev->id) {
case GPIO_50PINS_PULLUPDOWN: case GPIO_50PINS_PULLUPDOWN:
...@@ -489,21 +488,14 @@ static int giu_probe(struct platform_device *pdev) ...@@ -489,21 +488,14 @@ static int giu_probe(struct platform_device *pdev)
return -ENODEV; return -ENODEV;
} }
res = platform_get_resource(pdev, IORESOURCE_MEM, 0); giu_base = devm_platform_ioremap_resource(pdev, 0);
if (!res) if (IS_ERR(giu_base))
return -EBUSY; return PTR_ERR(giu_base);
giu_base = ioremap(res->start, resource_size(res));
if (!giu_base)
return -ENOMEM;
vr41xx_gpio_chip.parent = &pdev->dev; vr41xx_gpio_chip.parent = &pdev->dev;
ret = gpiochip_add_data(&vr41xx_gpio_chip, NULL); if (gpiochip_add_data(&vr41xx_gpio_chip, NULL))
if (!ret) {
iounmap(giu_base);
return -ENODEV; return -ENODEV;
}
giu_write(GIUINTENL, 0); giu_write(GIUINTENL, 0);
giu_write(GIUINTENH, 0); giu_write(GIUINTENH, 0);
...@@ -534,7 +526,6 @@ static int giu_probe(struct platform_device *pdev) ...@@ -534,7 +526,6 @@ static int giu_probe(struct platform_device *pdev)
static int giu_remove(struct platform_device *pdev) static int giu_remove(struct platform_device *pdev)
{ {
if (giu_base) { if (giu_base) {
iounmap(giu_base);
giu_base = NULL; giu_base = NULL;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment