diff options
author | Uwe Kleine-König <u.kleine-koenig@pengutronix.de> | 2023-03-31 00:03:40 +0300 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2023-04-04 14:46:48 +0300 |
commit | 61f49171a43ab1f80c73c5c88c508770c461e0f2 (patch) | |
tree | 636a2c56fa0790e703d881633497f26c39ed08aa /drivers/spi/spi-qup.c | |
parent | c2912d42e86e494935722669e4d9eade69649072 (diff) | |
download | linux-61f49171a43ab1f80c73c5c88c508770c461e0f2.tar.xz |
spi: qup: Don't skip cleanup in remove's error path
Returning early in a platform driver's remove callback is wrong. In this
case the dma resources are not released in the error path. this is never
retried later and so this is a permanent leak. To fix this, only skip
hardware disabling if waking the device fails.
Fixes: 64ff247a978f ("spi: Add Qualcomm QUP SPI controller support")
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Link: https://lore.kernel.org/r/20230330210341.2459548-2-u.kleine-koenig@pengutronix.de
Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'drivers/spi/spi-qup.c')
-rw-r--r-- | drivers/spi/spi-qup.c | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/drivers/spi/spi-qup.c b/drivers/spi/spi-qup.c index 71fc65e094e7..9efa56e2ee9d 100644 --- a/drivers/spi/spi-qup.c +++ b/drivers/spi/spi-qup.c @@ -1276,18 +1276,22 @@ static int spi_qup_remove(struct platform_device *pdev) struct spi_qup *controller = spi_master_get_devdata(master); int ret; - ret = pm_runtime_resume_and_get(&pdev->dev); - if (ret < 0) - return ret; + ret = pm_runtime_get_sync(&pdev->dev); - ret = spi_qup_set_state(controller, QUP_STATE_RESET); - if (ret) - return ret; + if (ret >= 0) { + ret = spi_qup_set_state(controller, QUP_STATE_RESET); + if (ret) + dev_warn(&pdev->dev, "failed to reset controller (%pe)\n", + ERR_PTR(ret)); - spi_qup_release_dma(master); + clk_disable_unprepare(controller->cclk); + clk_disable_unprepare(controller->iclk); + } else { + dev_warn(&pdev->dev, "failed to resume, skip hw disable (%pe)\n", + ERR_PTR(ret)); + } - clk_disable_unprepare(controller->cclk); - clk_disable_unprepare(controller->iclk); + spi_qup_release_dma(master); pm_runtime_put_noidle(&pdev->dev); pm_runtime_disable(&pdev->dev); |