spi: qup: 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/20260505072909.618363-5-johan@kernel.org
Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
Johan Hovold 2026-05-05 09:28:53 +02:00 committed by Mark Brown
parent 02efc5557c
commit 86e8160240
No known key found for this signature in database
GPG Key ID: 24D68B725D5487D0

View File

@ -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[] = {