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

index 9c8099fe6e19fff6d7568700e5f93bf2ee2b15db..df61094fc44460f7c57e0f1cbb4552990a272e33 100644 (file)
@@ -279,7 +279,7 @@ static int spi_st_probe(struct platform_device *pdev)
        int irq, ret = 0;
        u32 var;
 
-       host = spi_alloc_host(&pdev->dev, sizeof(*spi_st));
+       host = devm_spi_alloc_host(&pdev->dev, sizeof(*spi_st));
        if (!host)
                return -ENOMEM;
 
@@ -296,13 +296,12 @@ static int spi_st_probe(struct platform_device *pdev)
        spi_st->clk = devm_clk_get(&pdev->dev, "ssc");
        if (IS_ERR(spi_st->clk)) {
                dev_err(&pdev->dev, "Unable to request clock\n");
-               ret = PTR_ERR(spi_st->clk);
-               goto put_host;
+               return PTR_ERR(spi_st->clk);
        }
 
        ret = clk_prepare_enable(spi_st->clk);
        if (ret)
-               goto put_host;
+               return ret;
 
        init_completion(&spi_st->done);
 
@@ -361,8 +360,7 @@ rpm_disable:
        pm_runtime_disable(&pdev->dev);
 clk_disable:
        clk_disable_unprepare(spi_st->clk);
-put_host:
-       spi_controller_put(host);
+
        return ret;
 }
 
@@ -371,16 +369,12 @@ static void spi_st_remove(struct platform_device *pdev)
        struct spi_controller *host = platform_get_drvdata(pdev);
        struct spi_st *spi_st = spi_controller_get_devdata(host);
 
-       spi_controller_get(host);
-
        spi_unregister_controller(host);
 
        pm_runtime_disable(&pdev->dev);
 
        clk_disable_unprepare(spi_st->clk);
 
-       spi_controller_put(host);
-
        pinctrl_pm_select_sleep_state(&pdev->dev);
 }