diff mbox series

pwm: bcm-kona: Don't modify HW state in .remove callback

Message ID 20210326081804.117843-1-u.kleine-koenig@pengutronix.de
State Accepted
Headers show
Series pwm: bcm-kona: Don't modify HW state in .remove callback | expand

Commit Message

Uwe Kleine-König March 26, 2021, 8:18 a.m. UTC
A consumer is expected to disable a PWM before calling pwm_put(). And if
they didn't there is hopefully a good reason (or the consumer needs
fixing.) Also if disabling an enabled PWM was the right thing to do, this
should better be done in the framework instead of in each low level driver.

So drop the hardware modification from the .remove() callback.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 drivers/pwm/pwm-bcm-kona.c | 5 -----
 1 file changed, 5 deletions(-)

Comments

Thierry Reding April 9, 2021, 12:43 p.m. UTC | #1
On Fri, Mar 26, 2021 at 09:18:04AM +0100, Uwe Kleine-König wrote:
> A consumer is expected to disable a PWM before calling pwm_put(). And if
> they didn't there is hopefully a good reason (or the consumer needs
> fixing.) Also if disabling an enabled PWM was the right thing to do, this
> should better be done in the framework instead of in each low level driver.
> 
> So drop the hardware modification from the .remove() callback.
> 
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> ---
>  drivers/pwm/pwm-bcm-kona.c | 5 -----
>  1 file changed, 5 deletions(-)

It'd be better to somehow WARN about this instead of silently leaking
the clock reference, but I can't think of a good way to do that, which
would also work in the case where the consumer intentionally left the
PWM enabled, so:

Applied, thanks.

Thierry
diff mbox series

Patch

diff --git a/drivers/pwm/pwm-bcm-kona.c b/drivers/pwm/pwm-bcm-kona.c
index f09a31042859..800b9edf2e71 100644
--- a/drivers/pwm/pwm-bcm-kona.c
+++ b/drivers/pwm/pwm-bcm-kona.c
@@ -310,11 +310,6 @@  static int kona_pwmc_probe(struct platform_device *pdev)
 static int kona_pwmc_remove(struct platform_device *pdev)
 {
 	struct kona_pwmc *kp = platform_get_drvdata(pdev);
-	unsigned int chan;
-
-	for (chan = 0; chan < kp->chip.npwm; chan++)
-		if (pwm_is_enabled(&kp->chip.pwms[chan]))
-			clk_disable_unprepare(kp->clk);
 
 	return pwmchip_remove(&kp->chip);
 }