Skip to content

Commit

Permalink
gpio: mvebu: Make use of devm_pwmchip_add
Browse files Browse the repository at this point in the history
This allows to get rid of a call to pwmchip_remove() in the error path. There
is no .remove function for this driver, so this change fixes a resource leak
when a gpio-mvebu device is unbound.

Fixes: 757642f ("gpio: mvebu: Add limited PWM support")
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Reviewed-by: Andy Shevchenko <andy@kernel.org>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
  • Loading branch information
Uwe Kleine-König authored and Bartosz Golaszewski committed Jul 19, 2023
1 parent 5a7adc6 commit 1945063
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions drivers/gpio/gpio-mvebu.c
Original file line number Diff line number Diff line change
Expand Up @@ -874,7 +874,7 @@ static int mvebu_pwm_probe(struct platform_device *pdev,

spin_lock_init(&mvpwm->lock);

return pwmchip_add(&mvpwm->chip);
return devm_pwmchip_add(dev, &mvpwm->chip);
}

#ifdef CONFIG_DEBUG_FS
Expand Down Expand Up @@ -1243,8 +1243,7 @@ static int mvebu_gpio_probe(struct platform_device *pdev)
if (!mvchip->domain) {
dev_err(&pdev->dev, "couldn't allocate irq domain %s (DT).\n",
mvchip->chip.label);
err = -ENODEV;
goto err_pwm;
return -ENODEV;
}

err = irq_alloc_domain_generic_chips(
Expand Down Expand Up @@ -1296,9 +1295,6 @@ static int mvebu_gpio_probe(struct platform_device *pdev)

err_domain:
irq_domain_remove(mvchip->domain);
err_pwm:
pwmchip_remove(&mvchip->mvpwm->chip);

return err;
}

Expand Down

0 comments on commit 1945063

Please sign in to comment.