Unverified Commit 0df9f6cf authored by Mark Brown's avatar Mark Brown
Browse files

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.
parents a0dcd1ff 423e5481
Loading
Loading
Loading
Loading
+7 −11
Original line number Diff line number Diff line
@@ -1848,7 +1848,7 @@ static int spi_imx_probe(struct platform_device *pdev)
	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;
	}

	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);