[PATCH 19/19] spi: orion: switch to managed controller allocation
From: Johan Hovold
Date: Wed Apr 29 2026 - 05:14:58 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-orion.c | 26 ++++++++------------------
1 file changed, 8 insertions(+), 18 deletions(-)
diff --git a/drivers/spi/spi-orion.c b/drivers/spi/spi-orion.c
index 64bf215c1804..265708a94984 100644
--- a/drivers/spi/spi-orion.c
+++ b/drivers/spi/spi-orion.c
@@ -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 @@ static int orion_spi_probe(struct platform_device *pdev)
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);
--
2.53.0