summaryrefslogtreecommitdiffstats
path: root/drivers/pwm
diff options
context:
space:
mode:
authorGeert Uytterhoeven <geert+renesas@glider.be>2020-03-16 11:32:15 +0100
committerThierry Reding <thierry.reding@gmail.com>2020-03-30 18:03:05 +0200
commitd5a3c7a4536e1329a758e14340efd0e65252bd3d (patch)
treec3e6849751b15336e410bb3534cffef22fc14c50 /drivers/pwm
parent1451a3eed24b5fd6a604683f0b6995e0e7e16c79 (diff)
downloadlinux-stable-d5a3c7a4536e1329a758e14340efd0e65252bd3d.tar.gz
linux-stable-d5a3c7a4536e1329a758e14340efd0e65252bd3d.tar.bz2
linux-stable-d5a3c7a4536e1329a758e14340efd0e65252bd3d.zip
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: 99b82abb0a35b073 ("pwm: Add Renesas TPU PWM driver") Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
Diffstat (limited to 'drivers/pwm')
-rw-r--r--drivers/pwm/pwm-renesas-tpu.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/drivers/pwm/pwm-renesas-tpu.c b/drivers/pwm/pwm-renesas-tpu.c
index 4a855a21b782..8032acc84161 100644
--- a/drivers/pwm/pwm-renesas-tpu.c
+++ b/drivers/pwm/pwm-renesas-tpu.c
@@ -415,16 +415,17 @@ static int tpu_probe(struct platform_device *pdev)
tpu->chip.base = -1;
tpu->chip.npwm = TPU_CHANNEL_MAX;
+ pm_runtime_enable(&pdev->dev);
+
ret = pwmchip_add(&tpu->chip);
if (ret < 0) {
dev_err(&pdev->dev, "failed to register PWM chip\n");
+ pm_runtime_disable(&pdev->dev);
return ret;
}
dev_info(&pdev->dev, "TPU PWM %d registered\n", tpu->pdev->id);
- pm_runtime_enable(&pdev->dev);
-
return 0;
}
@@ -434,12 +435,10 @@ static int tpu_remove(struct platform_device *pdev)
int ret;
ret = pwmchip_remove(&tpu->chip);
- if (ret)
- return ret;
pm_runtime_disable(&pdev->dev);
- return 0;
+ return ret;
}
#ifdef CONFIG_OF