]> git.baikalelectronics.ru Git - kernel.git/commitdiff
pwm: sifive: Shut down hardware only after pwmchip_remove() completed
authorUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Thu, 21 Jul 2022 10:31:29 +0000 (12:31 +0200)
committerThierry Reding <thierry.reding@gmail.com>
Fri, 29 Jul 2022 11:41:13 +0000 (13:41 +0200)
The PWMs are expected to be functional until pwmchip_remove() is called.
So disable the clks only afterwards.

Fixes: 1afcd3819818 ("pwm: sifive: Add a driver for SiFive SoC PWM")
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Tested-by: Emil Renner Berthing <emil.renner.berthing@canonical.com>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
drivers/pwm/pwm-sifive.c

index da40ade0ebdf7db010c7c6728606a5a1d6d5af81..2d4fa5e5fdd462798364338ce5ea55e0cb720b3f 100644 (file)
@@ -308,6 +308,9 @@ static int pwm_sifive_remove(struct platform_device *dev)
        struct pwm_device *pwm;
        int ch;
 
+       pwmchip_remove(&ddata->chip);
+       clk_notifier_unregister(ddata->clk, &ddata->notifier);
+
        for (ch = 0; ch < ddata->chip.npwm; ch++) {
                pwm = &ddata->chip.pwms[ch];
                if (pwm->state.enabled)
@@ -315,8 +318,6 @@ static int pwm_sifive_remove(struct platform_device *dev)
        }
 
        clk_unprepare(ddata->clk);
-       pwmchip_remove(&ddata->chip);
-       clk_notifier_unregister(ddata->clk, &ddata->notifier);
 
        return 0;
 }