Skip to content

Commit 0df9f6c

Browse files
committed
spi: imx: Fix cleanup in remove and convert to
Merge series from Uwe Kleine-König <u.kleine-koenig@pengutronix.de>: 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.
2 parents a0dcd1f + 423e548 commit 0df9f6c

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

drivers/spi/spi-imx.c

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1848,29 +1848,25 @@ static int spi_imx_probe(struct platform_device *pdev)
18481848
return ret;
18491849
}
18501850

1851-
static int spi_imx_remove(struct platform_device *pdev)
1851+
static void spi_imx_remove(struct platform_device *pdev)
18521852
{
18531853
struct spi_controller *controller = platform_get_drvdata(pdev);
18541854
struct spi_imx_data *spi_imx = spi_controller_get_devdata(controller);
18551855
int ret;
18561856

18571857
spi_unregister_controller(controller);
18581858

1859-
ret = pm_runtime_resume_and_get(spi_imx->dev);
1860-
if (ret < 0) {
1861-
dev_err(spi_imx->dev, "failed to enable clock\n");
1862-
return ret;
1863-
}
1864-
1865-
writel(0, spi_imx->base + MXC_CSPICTRL);
1859+
ret = pm_runtime_get_sync(spi_imx->dev);
1860+
if (ret >= 0)
1861+
writel(0, spi_imx->base + MXC_CSPICTRL);
1862+
else
1863+
dev_warn(spi_imx->dev, "failed to enable clock, skip hw disable\n");
18661864

18671865
pm_runtime_dont_use_autosuspend(spi_imx->dev);
18681866
pm_runtime_put_sync(spi_imx->dev);
18691867
pm_runtime_disable(spi_imx->dev);
18701868

18711869
spi_imx_sdma_exit(spi_imx);
1872-
1873-
return 0;
18741870
}
18751871

18761872
static int __maybe_unused spi_imx_runtime_resume(struct device *dev)
@@ -1932,7 +1928,7 @@ static struct platform_driver spi_imx_driver = {
19321928
.pm = &imx_spi_pm,
19331929
},
19341930
.probe = spi_imx_probe,
1935-
.remove = spi_imx_remove,
1931+
.remove_new = spi_imx_remove,
19361932
};
19371933
module_platform_driver(spi_imx_driver);
19381934

0 commit comments

Comments
 (0)