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

index 64bf215c180475f086b5b99a6e49d350c648c227..265708a949843b5a7f109f2950008aec64687334 100644 (file)
@@ -651,11 +651,9 @@ static int orion_spi_probe(struct platform_device *pdev)
        struct device_node *np;
        int status;
 
-       host = spi_alloc_host(&pdev->dev, sizeof(*spi));
-       if (host == NULL) {
-               dev_dbg(&pdev->dev, "host allocation failed\n");
+       host = devm_spi_alloc_host(&pdev->dev, sizeof(*spi));
+       if (host == NULL)
                return -ENOMEM;
-       }
 
        if (pdev->id != -1)
                host->bus_num = pdev->id;
@@ -689,17 +687,14 @@ static int orion_spi_probe(struct platform_device *pdev)
        spi->devdata = devdata;
 
        spi->clk = devm_clk_get_enabled(&pdev->dev, NULL);
-       if (IS_ERR(spi->clk)) {
-               status = PTR_ERR(spi->clk);
-               goto out;
-       }
+       if (IS_ERR(spi->clk))
+               return PTR_ERR(spi->clk);
 
        /* The following clock is only used by some SoCs */
        spi->axi_clk = devm_clk_get(&pdev->dev, "axi");
-       if (PTR_ERR(spi->axi_clk) == -EPROBE_DEFER) {
-               status = -EPROBE_DEFER;
-               goto out;
-       }
+       if (PTR_ERR(spi->axi_clk) == -EPROBE_DEFER)
+               return -EPROBE_DEFER;
+
        if (!IS_ERR(spi->axi_clk))
                clk_prepare_enable(spi->axi_clk);
 
@@ -796,8 +791,7 @@ out_rel_pm:
        pm_runtime_dont_use_autosuspend(&pdev->dev);
 out_rel_axi_clk:
        clk_disable_unprepare(spi->axi_clk);
-out:
-       spi_controller_put(host);
+
        return status;
 }
 
@@ -807,15 +801,11 @@ static void orion_spi_remove(struct platform_device *pdev)
        struct spi_controller *host = platform_get_drvdata(pdev);
        struct orion_spi *spi = spi_controller_get_devdata(host);
 
-       spi_controller_get(host);
-
        spi_unregister_controller(host);
 
        pm_runtime_get_sync(&pdev->dev);
        clk_disable_unprepare(spi->axi_clk);
 
-       spi_controller_put(host);
-
        pm_runtime_disable(&pdev->dev);
        pm_runtime_put_noidle(&pdev->dev);
        pm_runtime_set_suspended(&pdev->dev);