[PATCH 04/20] spi: qup: switch to managed controller allocation

From: Johan Hovold

Date: Tue May 05 2026 - 03:30:00 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-qup.c | 15 ++++-----------
1 file changed, 4 insertions(+), 11 deletions(-)

diff --git a/drivers/spi/spi-qup.c b/drivers/spi/spi-qup.c
index 45d9b4cb75e4..4df01ef2e662 100644
--- a/drivers/spi/spi-qup.c
+++ b/drivers/spi/spi-qup.c
@@ -1071,11 +1071,9 @@ static int spi_qup_probe(struct platform_device *pdev)
if (ret && ret != -ENODEV)
return dev_err_probe(dev, ret, "invalid OPP table\n");

- host = spi_alloc_host(dev, sizeof(struct spi_qup));
- if (!host) {
- dev_err(dev, "cannot allocate host\n");
+ host = devm_spi_alloc_host(dev, sizeof(struct spi_qup));
+ if (!host)
return -ENOMEM;
- }

/* use num-cs unless not present or out of range */
if (of_property_read_u32(dev->of_node, "num-cs", &num_cs) ||
@@ -1108,7 +1106,7 @@ static int spi_qup_probe(struct platform_device *pdev)

ret = spi_qup_init_dma(host, res->start);
if (ret == -EPROBE_DEFER)
- goto error;
+ return ret;
else if (!ret)
host->can_dma = spi_qup_can_dma;

@@ -1206,8 +1204,7 @@ static int spi_qup_probe(struct platform_device *pdev)
clk_disable_unprepare(iclk);
error_dma:
spi_qup_release_dma(host);
-error:
- spi_controller_put(host);
+
return ret;
}

@@ -1320,8 +1317,6 @@ static void spi_qup_remove(struct platform_device *pdev)
struct spi_qup *controller = spi_controller_get_devdata(host);
int ret;

- spi_controller_get(host);
-
spi_unregister_controller(host);

ret = pm_runtime_get_sync(&pdev->dev);
@@ -1343,8 +1338,6 @@ static void spi_qup_remove(struct platform_device *pdev)

pm_runtime_put_noidle(&pdev->dev);
pm_runtime_disable(&pdev->dev);
-
- spi_controller_put(host);
}

static const struct of_device_id spi_qup_dt_match[] = {
--
2.53.0