]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
spi: tegra114: switch to managed controller allocation
authorJohan Hovold <johan@kernel.org>
Tue, 5 May 2026 07:29:04 +0000 (09:29 +0200)
committerMark Brown <broonie@kernel.org>
Mon, 11 May 2026 00:55:51 +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-16-johan@kernel.org
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/spi/spi-tegra114.c

index b8b0ebe0fe931d57b10d6a80aa77e5c161c2077c..aa44ffd09e61b009d6f1be7c71d2d7de15618a55 100644 (file)
@@ -1302,7 +1302,7 @@ static int tegra_spi_probe(struct platform_device *pdev)
        int ret, spi_irq;
        int bus_num;
 
-       host = spi_alloc_host(&pdev->dev, sizeof(*tspi));
+       host = devm_spi_alloc_host(&pdev->dev, sizeof(*tspi));
        if (!host) {
                dev_err(&pdev->dev, "host allocation failed\n");
                return -ENOMEM;
@@ -1336,36 +1336,31 @@ static int tegra_spi_probe(struct platform_device *pdev)
        tspi->soc_data = of_device_get_match_data(&pdev->dev);
        if (!tspi->soc_data) {
                dev_err(&pdev->dev, "unsupported tegra\n");
-               ret = -ENODEV;
-               goto exit_free_host;
+               return -ENODEV;
        }
 
        tspi->base = devm_platform_get_and_ioremap_resource(pdev, 0, &r);
-       if (IS_ERR(tspi->base)) {
-               ret = PTR_ERR(tspi->base);
-               goto exit_free_host;
-       }
+       if (IS_ERR(tspi->base))
+               return PTR_ERR(tspi->base);
+
        tspi->phys = r->start;
 
        spi_irq = platform_get_irq(pdev, 0);
-       if (spi_irq < 0) {
-               ret = spi_irq;
-               goto exit_free_host;
-       }
+       if (spi_irq < 0)
+               return spi_irq;
+
        tspi->irq = spi_irq;
 
        tspi->clk = devm_clk_get(&pdev->dev, "spi");
        if (IS_ERR(tspi->clk)) {
                dev_err(&pdev->dev, "can not get clock\n");
-               ret = PTR_ERR(tspi->clk);
-               goto exit_free_host;
+               return PTR_ERR(tspi->clk);
        }
 
        tspi->rst = devm_reset_control_get_exclusive(&pdev->dev, "spi");
        if (IS_ERR(tspi->rst)) {
                dev_err(&pdev->dev, "can not get reset\n");
-               ret = PTR_ERR(tspi->rst);
-               goto exit_free_host;
+               return PTR_ERR(tspi->rst);
        }
 
        tspi->max_buf_size = SPI_FIFO_DEPTH << 2;
@@ -1373,7 +1368,7 @@ static int tegra_spi_probe(struct platform_device *pdev)
 
        ret = tegra_spi_init_dma_param(tspi, true);
        if (ret < 0)
-               goto exit_free_host;
+               return ret;
        ret = tegra_spi_init_dma_param(tspi, false);
        if (ret < 0)
                goto exit_rx_dma_free;
@@ -1431,8 +1426,7 @@ exit_pm_disable:
        tegra_spi_deinit_dma_param(tspi, false);
 exit_rx_dma_free:
        tegra_spi_deinit_dma_param(tspi, true);
-exit_free_host:
-       spi_controller_put(host);
+
        return ret;
 }
 
@@ -1441,8 +1435,6 @@ static void tegra_spi_remove(struct platform_device *pdev)
        struct spi_controller *host = platform_get_drvdata(pdev);
        struct tegra_spi_data   *tspi = spi_controller_get_devdata(host);
 
-       spi_controller_get(host);
-
        spi_unregister_controller(host);
 
        free_irq(tspi->irq, tspi);
@@ -1456,8 +1448,6 @@ static void tegra_spi_remove(struct platform_device *pdev)
        pm_runtime_disable(&pdev->dev);
        if (!pm_runtime_status_suspended(&pdev->dev))
                tegra_spi_runtime_suspend(&pdev->dev);
-
-       spi_controller_put(host);
 }
 
 #ifdef CONFIG_PM_SLEEP