Skip to content

Commit

Permalink
pwm: renesas-tpu: Make use of devm functions
Browse files Browse the repository at this point in the history
This simplifies an error path in .probe() and allows to drop the .remove()
function.

Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
  • Loading branch information
Uwe Kleine-König authored and thierryreding committed May 20, 2022
1 parent 6eb3af7 commit ff4bcd5
Showing 1 changed file with 5 additions and 17 deletions.
22 changes: 5 additions & 17 deletions drivers/pwm/pwm-renesas-tpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -408,24 +408,13 @@ static int tpu_probe(struct platform_device *pdev)
tpu->chip.ops = &tpu_pwm_ops;
tpu->chip.npwm = TPU_CHANNEL_MAX;

pm_runtime_enable(&pdev->dev);
ret = devm_pm_runtime_enable(&pdev->dev);
if (ret < 0)
return dev_err_probe(&pdev->dev, ret, "Failed to enable runtime PM\n");

ret = pwmchip_add(&tpu->chip);
if (ret < 0) {
pm_runtime_disable(&pdev->dev);
ret = devm_pwmchip_add(&pdev->dev, &tpu->chip);
if (ret < 0)
return dev_err_probe(&pdev->dev, ret, "Failed to register PWM chip\n");
}

return 0;
}

static int tpu_remove(struct platform_device *pdev)
{
struct tpu_device *tpu = platform_get_drvdata(pdev);

pwmchip_remove(&tpu->chip);

pm_runtime_disable(&pdev->dev);

return 0;
}
Expand All @@ -444,7 +433,6 @@ MODULE_DEVICE_TABLE(of, tpu_of_table);

static struct platform_driver tpu_driver = {
.probe = tpu_probe,
.remove = tpu_remove,
.driver = {
.name = "renesas-tpu-pwm",
.of_match_table = of_match_ptr(tpu_of_table),
Expand Down

0 comments on commit ff4bcd5

Please sign in to comment.