pwm: lpc18xx-sct: Free resources only after pwmchip_remove()
authorUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Sat, 27 Mar 2021 21:24:28 +0000 (22:24 +0100)
committerThierry Reding <thierry.reding@gmail.com>
Fri, 9 Apr 2021 12:44:37 +0000 (14:44 +0200)
Before pwmchip_remove() returns the PWM is expected to be functional. So
remove the pwmchip before disabling the clock.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Acked-by: Vladimir Zapolskiy <vz@mleia.com>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
drivers/pwm/pwm-lpc18xx-sct.c

index 3f8e54e..b643ac6 100644 (file)
@@ -441,13 +441,15 @@ static int lpc18xx_pwm_remove(struct platform_device *pdev)
        struct lpc18xx_pwm_chip *lpc18xx_pwm = platform_get_drvdata(pdev);
        u32 val;
 
+       pwmchip_remove(&lpc18xx_pwm->chip);
+
        val = lpc18xx_pwm_readl(lpc18xx_pwm, LPC18XX_PWM_CTRL);
        lpc18xx_pwm_writel(lpc18xx_pwm, LPC18XX_PWM_CTRL,
                           val | LPC18XX_PWM_CTRL_HALT);
 
        clk_disable_unprepare(lpc18xx_pwm->pwm_clk);
 
-       return pwmchip_remove(&lpc18xx_pwm->chip);
+       return 0;
 }
 
 static struct platform_driver lpc18xx_pwm_driver = {