Commit d5a3c7a4 authored by Geert Uytterhoeven's avatar Geert Uytterhoeven Committed by Thierry Reding

pwm: renesas-tpu: Fix late Runtime PM enablement

Runtime PM should be enabled before calling pwmchip_add(), as PWM users
can appear immediately after the PWM chip has been added.
Likewise, Runtime PM should always be disabled after the removal of the
PWM chip, even if the latter failed.

Fixes: 99b82abb ("pwm: Add Renesas TPU PWM driver")
Signed-off-by: default avatarGeert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: default avatarThierry Reding <thierry.reding@gmail.com>
parent 1451a3ee
...@@ -415,16 +415,17 @@ static int tpu_probe(struct platform_device *pdev) ...@@ -415,16 +415,17 @@ static int tpu_probe(struct platform_device *pdev)
tpu->chip.base = -1; tpu->chip.base = -1;
tpu->chip.npwm = TPU_CHANNEL_MAX; tpu->chip.npwm = TPU_CHANNEL_MAX;
pm_runtime_enable(&pdev->dev);
ret = pwmchip_add(&tpu->chip); ret = pwmchip_add(&tpu->chip);
if (ret < 0) { if (ret < 0) {
dev_err(&pdev->dev, "failed to register PWM chip\n"); dev_err(&pdev->dev, "failed to register PWM chip\n");
pm_runtime_disable(&pdev->dev);
return ret; return ret;
} }
dev_info(&pdev->dev, "TPU PWM %d registered\n", tpu->pdev->id); dev_info(&pdev->dev, "TPU PWM %d registered\n", tpu->pdev->id);
pm_runtime_enable(&pdev->dev);
return 0; return 0;
} }
...@@ -434,12 +435,10 @@ static int tpu_remove(struct platform_device *pdev) ...@@ -434,12 +435,10 @@ static int tpu_remove(struct platform_device *pdev)
int ret; int ret;
ret = pwmchip_remove(&tpu->chip); ret = pwmchip_remove(&tpu->chip);
if (ret)
return ret;
pm_runtime_disable(&pdev->dev); pm_runtime_disable(&pdev->dev);
return 0; return ret;
} }
#ifdef CONFIG_OF #ifdef CONFIG_OF
......
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