]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
spi: mxs: switch to managed controller allocation
authorJohan Hovold <johan@kernel.org>
Wed, 29 Apr 2026 09:13:30 +0000 (11:13 +0200)
committerMark Brown <broonie@kernel.org>
Mon, 4 May 2026 13:09:30 +0000 (22:09 +0900)
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@kernel.org>
Link: https://patch.msgid.link/20260429091333.165363-17-johan@kernel.org
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/spi/spi-mxs.c

index 0164e04d59a10217dc23ac740b508a6d8339405c..fda1d260b296637dcbd3fca125bb816c67bff2e8 100644 (file)
@@ -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 @@ out_pm_runtime_disable:
        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 = {