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

index 1e3ca718ca736c02c808351b5a06a3435c046a47..f840467cfdb2c0b1970da2c9e1b5fb294a3ea05b 100644 (file)
@@ -224,15 +224,14 @@ static int hspi_probe(struct platform_device *pdev)
                return -EINVAL;
        }
 
-       ctlr = spi_alloc_host(&pdev->dev, sizeof(*hspi));
+       ctlr = devm_spi_alloc_host(&pdev->dev, sizeof(*hspi));
        if (!ctlr)
                return -ENOMEM;
 
        clk = clk_get(&pdev->dev, NULL);
        if (IS_ERR(clk)) {
                dev_err(&pdev->dev, "couldn't get clock\n");
-               ret = -EINVAL;
-               goto error0;
+               return PTR_ERR(clk);
        }
 
        hspi = spi_controller_get_devdata(ctlr);
@@ -269,8 +268,6 @@ static int hspi_probe(struct platform_device *pdev)
        pm_runtime_disable(&pdev->dev);
  error1:
        clk_put(clk);
- error0:
-       spi_controller_put(ctlr);
 
        return ret;
 }
@@ -279,15 +276,11 @@ static void hspi_remove(struct platform_device *pdev)
 {
        struct hspi_priv *hspi = platform_get_drvdata(pdev);
 
-       spi_controller_get(hspi->ctlr);
-
        spi_unregister_controller(hspi->ctlr);
 
        pm_runtime_disable(&pdev->dev);
 
        clk_put(hspi->clk);
-
-       spi_controller_put(hspi->ctlr);
 }
 
 static const struct of_device_id hspi_of_match[] = {