diff options
| author | Johan Hovold <johan@kernel.org> | 2026-04-29 12:13:33 +0300 |
|---|---|---|
| committer | Mark Brown <broonie@kernel.org> | 2026-05-04 16:09:32 +0300 |
| commit | bdab3707ddfdf89a054b2372a984316c84d3ce43 (patch) | |
| tree | a3e7cd1a1de01571fff35a925b0b0e3d1740da94 | |
| parent | c0c6875f0b7de6094f15ffd5b1dcebb3cebe53e1 (diff) | |
| download | linux-bdab3707ddfdf89a054b2372a984316c84d3ce43.tar.xz | |
spi: orion: switch to managed controller allocation
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>
| -rw-r--r-- | drivers/spi/spi-orion.c | 26 |
1 files 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 @@ 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); |
