aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Brown <[email protected]>2023-03-20 18:49:58 +0000
committerMark Brown <[email protected]>2023-03-20 18:49:58 +0000
commit0df9f6cf9576558fb1aba8527a66775e96e2bd2b (patch)
treeb681155abfce7b4dbcabf7e70348ff8c931e59c8
parenta0dcd1ff96293775c3ec30ae0091713982c5c24c (diff)
parent423e548127223d597bb65a149ebcb3c50ea08846 (diff)
spi: imx: Fix cleanup in remove and convert to
Merge series from Uwe Kleine-König <[email protected]>: This small series converts the spi-imx driver to .remove_new(). The motivation for this tree-wide effort are drivers that don't properly cleanup and return an error code. This is broken as this results in resource leaks. The spi-imx driver is such a driver. The idea is that if the remove callback returns void it's obvious that an early error return is wrong.
-rw-r--r--drivers/spi/spi-imx.c18
1 files changed, 7 insertions, 11 deletions
diff --git a/drivers/spi/spi-imx.c b/drivers/spi/spi-imx.c
index 620bce96b1f9..1f2c7ad65ec8 100644
--- a/drivers/spi/spi-imx.c
+++ b/drivers/spi/spi-imx.c
@@ -1848,7 +1848,7 @@ out_controller_put:
return ret;
}
-static int spi_imx_remove(struct platform_device *pdev)
+static void spi_imx_remove(struct platform_device *pdev)
{
struct spi_controller *controller = platform_get_drvdata(pdev);
struct spi_imx_data *spi_imx = spi_controller_get_devdata(controller);
@@ -1856,21 +1856,17 @@ static int spi_imx_remove(struct platform_device *pdev)
spi_unregister_controller(controller);
- ret = pm_runtime_resume_and_get(spi_imx->dev);
- if (ret < 0) {
- dev_err(spi_imx->dev, "failed to enable clock\n");
- return ret;
- }
-
- writel(0, spi_imx->base + MXC_CSPICTRL);
+ ret = pm_runtime_get_sync(spi_imx->dev);
+ if (ret >= 0)
+ writel(0, spi_imx->base + MXC_CSPICTRL);
+ else
+ dev_warn(spi_imx->dev, "failed to enable clock, skip hw disable\n");
pm_runtime_dont_use_autosuspend(spi_imx->dev);
pm_runtime_put_sync(spi_imx->dev);
pm_runtime_disable(spi_imx->dev);
spi_imx_sdma_exit(spi_imx);
-
- return 0;
}
static int __maybe_unused spi_imx_runtime_resume(struct device *dev)
@@ -1932,7 +1928,7 @@ static struct platform_driver spi_imx_driver = {
.pm = &imx_spi_pm,
},
.probe = spi_imx_probe,
- .remove = spi_imx_remove,
+ .remove_new = spi_imx_remove,
};
module_platform_driver(spi_imx_driver);