]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
spi: qup: switch to managed controller allocation
authorJohan Hovold <johan@kernel.org>
Tue, 5 May 2026 07:28:53 +0000 (09:28 +0200)
committerMark Brown <broonie@kernel.org>
Mon, 11 May 2026 00:55:41 +0000 (09:55 +0900)
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>
drivers/spi/spi-qup.c

index 45d9b4cb75e4aaaf5b508f9c456b6b612ca03012..4df01ef2e6622429c7d6228d102cdf128b366719 100644 (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 @@ 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[] = {