[PATCH 16/19] spi: mxs: switch to managed controller allocation

From: Johan Hovold

Date: Wed Apr 29 2026 - 05:14:54 EST


Switch to device managed controller allocation to simplify error
handling and to avoid having to take another reference during
deregistration.

Signed-off-by: Johan Hovold <johan@xxxxxxxxxx>
---
drivers/spi/spi-mxs.c | 14 ++++----------
1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/drivers/spi/spi-mxs.c b/drivers/spi/spi-mxs.c
index 0164e04d59a1..fda1d260b296 100644
--- a/drivers/spi/spi-mxs.c
+++ b/drivers/spi/spi-mxs.c
@@ -563,7 +563,7 @@ static int mxs_spi_probe(struct platform_device *pdev)
if (ret)
clk_freq = clk_freq_default;

- host = spi_alloc_host(&pdev->dev, sizeof(*spi));
+ host = devm_spi_alloc_host(&pdev->dev, sizeof(*spi));
if (!host)
return -ENOMEM;

@@ -589,13 +589,12 @@ static int mxs_spi_probe(struct platform_device *pdev)
ret = devm_request_irq(&pdev->dev, irq_err, mxs_ssp_irq_handler, 0,
dev_name(&pdev->dev), ssp);
if (ret)
- goto out_host_free;
+ return ret;

ssp->dmach = dma_request_chan(&pdev->dev, "rx-tx");
if (IS_ERR(ssp->dmach)) {
dev_err(ssp->dev, "Failed to request DMA\n");
- ret = PTR_ERR(ssp->dmach);
- goto out_host_free;
+ return PTR_ERR(ssp->dmach);
}

pm_runtime_enable(ssp->dev);
@@ -635,8 +634,7 @@ static int mxs_spi_probe(struct platform_device *pdev)
pm_runtime_disable(ssp->dev);
out_dma_release:
dma_release_channel(ssp->dmach);
-out_host_free:
- spi_controller_put(host);
+
return ret;
}

@@ -650,8 +648,6 @@ static void mxs_spi_remove(struct platform_device *pdev)
spi = spi_controller_get_devdata(host);
ssp = &spi->ssp;

- spi_controller_get(host);
-
spi_unregister_controller(host);

pm_runtime_disable(&pdev->dev);
@@ -659,8 +655,6 @@ static void mxs_spi_remove(struct platform_device *pdev)
mxs_spi_runtime_suspend(&pdev->dev);

dma_release_channel(ssp->dmach);
-
- spi_controller_put(host);
}

static struct platform_driver mxs_spi_driver = {
--
2.53.0