Commit 5b6a342b authored by Axel Lin's avatar Axel Lin Committed by Linus Walleij

gpio: vx855: Switch to use managed resources APIs

Use devm_* APIs to simplify the code a bit.
Signed-off-by: default avatarAxel Lin <>
Acked-by: default avatarAlexandre Courbot <>
Signed-off-by: Linus Walleij's avatarLinus Walleij <>
parent c458e450
......@@ -52,8 +52,6 @@ struct vx855_gpio {
spinlock_t lock;
u32 io_gpi;
u32 io_gpo;
bool gpi_reserved;
bool gpo_reserved;
/* resolve a GPIx into the corresponding bit position */
......@@ -224,14 +222,13 @@ static int vx855gpio_probe(struct platform_device *pdev)
struct resource *res_gpi;
struct resource *res_gpo;
struct vx855_gpio *vg;
int ret;
res_gpi = platform_get_resource(pdev, IORESOURCE_IO, 0);
res_gpo = platform_get_resource(pdev, IORESOURCE_IO, 1);
if (!res_gpi || !res_gpo)
return -EBUSY;
vg = kzalloc(sizeof(*vg), GFP_KERNEL);
vg = devm_kzalloc(&pdev->dev, sizeof(*vg), GFP_KERNEL);
if (!vg)
return -ENOMEM;
......@@ -250,56 +247,27 @@ static int vx855gpio_probe(struct platform_device *pdev)
* succeed. Ignore and continue.
if (!request_region(res_gpi->start, resource_size(res_gpi),
MODULE_NAME "_gpi"))
if (!devm_request_region(&pdev->dev, res_gpi->start,
resource_size(res_gpi), MODULE_NAME "_gpi"))
"GPI I/O resource busy, probably claimed by ACPI\n");
vg->gpi_reserved = true;
if (!request_region(res_gpo->start, resource_size(res_gpo),
MODULE_NAME "_gpo"))
if (!devm_request_region(&pdev->dev, res_gpo->start,
resource_size(res_gpo), MODULE_NAME "_gpo"))
"GPO I/O resource busy, probably claimed by ACPI\n");
vg->gpo_reserved = true;
ret = gpiochip_add(&vg->gpio);
if (ret) {
dev_err(&pdev->dev, "failed to register GPIOs\n");
goto out_release;
return 0;
if (vg->gpi_reserved)
release_region(res_gpi->start, resource_size(res_gpi));
if (vg->gpo_reserved)
release_region(res_gpi->start, resource_size(res_gpo));
return ret;
return gpiochip_add(&vg->gpio);
static int vx855gpio_remove(struct platform_device *pdev)
struct vx855_gpio *vg = platform_get_drvdata(pdev);
struct resource *res;
if (vg->gpi_reserved) {
res = platform_get_resource(pdev, IORESOURCE_IO, 0);
release_region(res->start, resource_size(res));
if (vg->gpo_reserved) {
res = platform_get_resource(pdev, IORESOURCE_IO, 1);
release_region(res->start, resource_size(res));
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