Skip to content

Commit

Permalink
pwm: sifive: Shut down hardware only after pwmchip_remove() completed
Browse files Browse the repository at this point in the history
[ Upstream commit 2375e96 ]

The PWMs are expected to be functional until pwmchip_remove() is called.
So disable the clks only afterwards.

Fixes: 9e37a53 ("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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
ukleinek authored and gregkh committed Aug 17, 2022
1 parent 53d7848 commit 009b384
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions drivers/pwm/pwm-sifive.c
Original file line number Diff line number Diff line change
Expand Up @@ -321,15 +321,16 @@ 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)
clk_disable(ddata->clk);
}

clk_unprepare(ddata->clk);
pwmchip_remove(&ddata->chip);
clk_notifier_unregister(ddata->clk, &ddata->notifier);

return 0;
}
Expand Down

0 comments on commit 009b384

Please sign in to comment.