From: Johan Hovold Date: Tue, 5 May 2026 07:28:53 +0000 (+0200) Subject: spi: qup: switch to managed controller allocation X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=86e8160240af1143e0a9f185e45ac300fe0d93a6;p=thirdparty%2Fkernel%2Flinux.git 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 Link: https://patch.msgid.link/20260505072909.618363-5-johan@kernel.org Signed-off-by: Mark Brown --- diff --git a/drivers/spi/spi-qup.c b/drivers/spi/spi-qup.c index 45d9b4cb75e4a..4df01ef2e6622 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 @@ error_clk: 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[] = {