pwm: spear: Free resources only after pwmchip_remove()
authorUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Wed, 28 Apr 2021 09:05:25 +0000 (11:05 +0200)
committerThierry Reding <thierry.reding@gmail.com>
Tue, 25 May 2021 16:42:54 +0000 (18:42 +0200)
Before pwmchip_remove() returns the PWM is expected to be functional. So
remove the pwmchip before disabling the clocks. The check for
pwmchip_remove()'s return value is dropped as this function returns
effectively always 0 and returning an error in a remove callback is
useless anyhow (as the device core ignores it and drops devm allocated
resources).

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

index 6879b49581b348654d0a6e37ba9b527b8d9071d3..05a19e70d57008bb6b81f009d05b52f1918a1163 100644 (file)
@@ -229,9 +229,12 @@ static int spear_pwm_remove(struct platform_device *pdev)
 {
        struct spear_pwm_chip *pc = platform_get_drvdata(pdev);
 
+       pwmchip_remove(&pc->chip);
+
        /* clk was prepared in probe, hence unprepare it here */
        clk_unprepare(pc->clk);
-       return pwmchip_remove(&pc->chip);
+
+       return 0;
 }
 
 static const struct of_device_id spear_pwm_of_match[] = {