mirror of
https://github.com/torvalds/linux.git
synced 2026-09-24 06:24:02 +02:00
spi: fsl-dspi: clean up after failed suspend and resume
dspi_suspend() disabled the IRQ before spi_controller_suspend(), but ignored a suspend failure and kept tearing the device down. Restore the IRQ and return the error if suspend fails. dspi_resume() also left the clock prepared if controller resume or hardware init failed. Route those failures through clock cleanup. Signed-off-by: Jiawen Liu <1298662399@qq.com> Link: https://patch.msgid.link/tencent_427FA55E3D59112524886E9C931CA0F92F06@qq.com Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
parent
faa878d480
commit
2543355f3d
|
|
@ -1464,10 +1464,18 @@ static int dspi_init(struct fsl_dspi *dspi)
|
|||
static int dspi_suspend(struct device *dev)
|
||||
{
|
||||
struct fsl_dspi *dspi = dev_get_drvdata(dev);
|
||||
int ret;
|
||||
|
||||
if (dspi->irq)
|
||||
disable_irq(dspi->irq);
|
||||
spi_controller_suspend(dspi->ctlr);
|
||||
|
||||
ret = spi_controller_suspend(dspi->ctlr);
|
||||
if (ret) {
|
||||
if (dspi->irq)
|
||||
enable_irq(dspi->irq);
|
||||
return ret;
|
||||
}
|
||||
|
||||
clk_disable_unprepare(dspi->clk);
|
||||
|
||||
pinctrl_pm_select_sleep_state(dev);
|
||||
|
|
@ -1485,12 +1493,15 @@ static int dspi_resume(struct device *dev)
|
|||
ret = clk_prepare_enable(dspi->clk);
|
||||
if (ret)
|
||||
return ret;
|
||||
spi_controller_resume(dspi->ctlr);
|
||||
|
||||
ret = spi_controller_resume(dspi->ctlr);
|
||||
if (ret)
|
||||
goto disable_clk;
|
||||
|
||||
ret = dspi_init(dspi);
|
||||
if (ret) {
|
||||
dev_err(dev, "failed to initialize dspi during resume\n");
|
||||
return ret;
|
||||
goto disable_clk;
|
||||
}
|
||||
|
||||
dspi_set_mtf(dspi);
|
||||
|
|
@ -1499,6 +1510,10 @@ static int dspi_resume(struct device *dev)
|
|||
enable_irq(dspi->irq);
|
||||
|
||||
return 0;
|
||||
|
||||
disable_clk:
|
||||
clk_disable_unprepare(dspi->clk);
|
||||
return ret;
|
||||
}
|
||||
#endif /* CONFIG_PM_SLEEP */
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user