]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
spi: ep93xx: switch to managed controller allocation
authorJohan Hovold <johan@kernel.org>
Wed, 29 Apr 2026 09:13:24 +0000 (11:13 +0200)
committerMark Brown <broonie@kernel.org>
Mon, 4 May 2026 13:09:25 +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-11-johan@kernel.org
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/spi/spi-ep93xx.c

index db50018050e5498536f7de3ef32ffbbc9c4fde23..d7e82d80c35a9e02600b037e2425cbe89c81ef00 100644 (file)
@@ -629,7 +629,7 @@ static int ep93xx_spi_probe(struct platform_device *pdev)
        if (irq < 0)
                return irq;
 
-       host = spi_alloc_host(&pdev->dev, sizeof(*espi));
+       host = devm_spi_alloc_host(&pdev->dev, sizeof(*espi));
        if (!host)
                return -ENOMEM;
 
@@ -654,8 +654,7 @@ static int ep93xx_spi_probe(struct platform_device *pdev)
        espi->clk = devm_clk_get(&pdev->dev, NULL);
        if (IS_ERR(espi->clk)) {
                dev_err(&pdev->dev, "unable to get spi clock\n");
-               error = PTR_ERR(espi->clk);
-               goto fail_release_host;
+               return PTR_ERR(espi->clk);
        }
 
        /*
@@ -666,22 +665,21 @@ static int ep93xx_spi_probe(struct platform_device *pdev)
        host->min_speed_hz = clk_get_rate(espi->clk) / (254 * 256);
 
        espi->mmio = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
-       if (IS_ERR(espi->mmio)) {
-               error = PTR_ERR(espi->mmio);
-               goto fail_release_host;
-       }
+       if (IS_ERR(espi->mmio))
+               return PTR_ERR(espi->mmio);
+
        espi->sspdr_phys = res->start + SSPDR;
 
        error = devm_request_irq(&pdev->dev, irq, ep93xx_spi_interrupt,
                                0, "ep93xx-spi", host);
        if (error) {
                dev_err(&pdev->dev, "failed to request irq\n");
-               goto fail_release_host;
+               return error;
        }
 
        error = ep93xx_spi_setup_dma(&pdev->dev, espi);
        if (error == -EPROBE_DEFER)
-               goto fail_release_host;
+               return error;
 
        if (error)
                dev_warn(&pdev->dev, "DMA setup failed. Falling back to PIO\n");
@@ -702,8 +700,6 @@ static int ep93xx_spi_probe(struct platform_device *pdev)
 
 fail_free_dma:
        ep93xx_spi_release_dma(espi);
-fail_release_host:
-       spi_controller_put(host);
 
        return error;
 }
@@ -713,13 +709,9 @@ static void ep93xx_spi_remove(struct platform_device *pdev)
        struct spi_controller *host = platform_get_drvdata(pdev);
        struct ep93xx_spi *espi = spi_controller_get_devdata(host);
 
-       spi_controller_get(host);
-
        spi_unregister_controller(host);
 
        ep93xx_spi_release_dma(espi);
-
-       spi_controller_put(host);
 }
 
 static const struct of_device_id ep93xx_spi_of_ids[] = {