Skip to content

Commit

Permalink
gpio: cs5535: Switch to using managed resources with devm_
Browse files Browse the repository at this point in the history
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: Pramod Gurav <pramod.gurav@smartplayin.com>
Reviewed-by: Alexandre Courbot <acourbot@nvidia.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
  • Loading branch information
Pramod Gurav authored and Linus Walleij committed Oct 21, 2014
1 parent 4515b76 commit 3eebd61
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions drivers/gpio/gpio-cs5535.c
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,8 @@ static int cs5535_gpio_probe(struct platform_device *pdev)
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");
goto done;
}
Expand All @@ -348,24 +349,18 @@ static int cs5535_gpio_probe(struct platform_device *pdev)
/* finally, register with the generic GPIO API */
err = gpiochip_add(&cs5535_gpio_chip.chip);
if (err)
goto release_region;
goto done;

return 0;

release_region:
release_region(res->start, resource_size(res));
done:
return err;
}

static int cs5535_gpio_remove(struct platform_device *pdev)
{
struct resource *r;

gpiochip_remove(&cs5535_gpio_chip.chip);

r = platform_get_resource(pdev, IORESOURCE_IO, 0);
release_region(r->start, resource_size(r));
return 0;
}

Expand Down

0 comments on commit 3eebd61

Please sign in to comment.