pwm: atmel-tcb: Only free resources after pwm_chip_remove() returned
authorUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Mon, 8 Mar 2021 09:51:50 +0000 (10:51 +0100)
committerThierry Reding <thierry.reding@gmail.com>
Mon, 22 Mar 2021 11:06:45 +0000 (12:06 +0100)
Otherwise the PWM stops working before the PWM core and its consumers
are aware the device is going away.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
drivers/pwm/pwm-atmel-tcb.c

index 4d2253f..8451d3e 100644 (file)
@@ -507,14 +507,14 @@ static int atmel_tcb_pwm_remove(struct platform_device *pdev)
        struct atmel_tcb_pwm_chip *tcbpwm = platform_get_drvdata(pdev);
        int err;
 
-       clk_disable_unprepare(tcbpwm->slow_clk);
-       clk_put(tcbpwm->slow_clk);
-       clk_put(tcbpwm->clk);
-
        err = pwmchip_remove(&tcbpwm->chip);
        if (err < 0)
                return err;
 
+       clk_disable_unprepare(tcbpwm->slow_clk);
+       clk_put(tcbpwm->slow_clk);
+       clk_put(tcbpwm->clk);
+
        return 0;
 }