Commit 3eebd613 authored by Pramod Gurav's avatar Pramod Gurav Committed by Linus Walleij

gpio: cs5535: Switch to using managed resources with devm_

This change switches to devm_request_region to request region
and hence simplifies the module unload and does away with
release_region in remove function.

Cc: linux-gpio@vger.kernel.org
Signed-off-by: default avatarPramod Gurav <pramod.gurav@smartplayin.com>
Reviewed-by: default avatarAlexandre Courbot <acourbot@nvidia.com>
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent 4515b76d
...@@ -322,7 +322,8 @@ static int cs5535_gpio_probe(struct platform_device *pdev) ...@@ -322,7 +322,8 @@ static int cs5535_gpio_probe(struct platform_device *pdev)
goto done; goto done;
} }
if (!request_region(res->start, resource_size(res), pdev->name)) { if (!devm_request_region(&pdev->dev, res->start, resource_size(res),
pdev->name)) {
dev_err(&pdev->dev, "can't request region\n"); dev_err(&pdev->dev, "can't request region\n");
goto done; goto done;
} }
...@@ -348,24 +349,18 @@ static int cs5535_gpio_probe(struct platform_device *pdev) ...@@ -348,24 +349,18 @@ static int cs5535_gpio_probe(struct platform_device *pdev)
/* finally, register with the generic GPIO API */ /* finally, register with the generic GPIO API */
err = gpiochip_add(&cs5535_gpio_chip.chip); err = gpiochip_add(&cs5535_gpio_chip.chip);
if (err) if (err)
goto release_region; goto done;
return 0; return 0;
release_region:
release_region(res->start, resource_size(res));
done: done:
return err; return err;
} }
static int cs5535_gpio_remove(struct platform_device *pdev) static int cs5535_gpio_remove(struct platform_device *pdev)
{ {
struct resource *r;
gpiochip_remove(&cs5535_gpio_chip.chip); gpiochip_remove(&cs5535_gpio_chip.chip);
r = platform_get_resource(pdev, IORESOURCE_IO, 0);
release_region(r->start, resource_size(r));
return 0; return 0;
} }
......
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