]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
spi: clps711x: switch to managed controller allocation
authorJohan Hovold <johan@kernel.org>
Mon, 11 May 2026 15:03:59 +0000 (17:03 +0200)
committerMark Brown <broonie@kernel.org>
Mon, 18 May 2026 09:19:43 +0000 (10:19 +0100)
Switch to device managed controller allocation for consistency and to
simplify error handling.

Signed-off-by: Johan Hovold <johan@kernel.org>
Link: https://patch.msgid.link/20260511150408.796155-4-johan@kernel.org
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/spi/spi-clps711x.c

index d6458e59d41b6d58012a531ac8891877643aa7cb..382c3c81c4b96d8db18b2a5412f4b4fe4cc3306b 100644 (file)
@@ -99,7 +99,7 @@ static int spi_clps711x_probe(struct platform_device *pdev)
        if (irq < 0)
                return irq;
 
-       host = spi_alloc_host(&pdev->dev, sizeof(*hw));
+       host = devm_spi_alloc_host(&pdev->dev, sizeof(*hw));
        if (!host)
                return -ENOMEM;
 
@@ -113,22 +113,16 @@ static int spi_clps711x_probe(struct platform_device *pdev)
        hw = spi_controller_get_devdata(host);
 
        hw->spi_clk = devm_clk_get(&pdev->dev, NULL);
-       if (IS_ERR(hw->spi_clk)) {
-               ret = PTR_ERR(hw->spi_clk);
-               goto err_out;
-       }
+       if (IS_ERR(hw->spi_clk))
+               return PTR_ERR(hw->spi_clk);
 
        hw->syscon = syscon_regmap_lookup_by_phandle(np, "syscon");
-       if (IS_ERR(hw->syscon)) {
-               ret = PTR_ERR(hw->syscon);
-               goto err_out;
-       }
+       if (IS_ERR(hw->syscon))
+               return PTR_ERR(hw->syscon);
 
        hw->syncio = devm_platform_ioremap_resource(pdev, 0);
-       if (IS_ERR(hw->syncio)) {
-               ret = PTR_ERR(hw->syncio);
-               goto err_out;
-       }
+       if (IS_ERR(hw->syncio))
+               return PTR_ERR(hw->syncio);
 
        /* Disable extended mode due hardware problems */
        regmap_update_bits(hw->syscon, SYSCON_OFFSET, SYSCON3_ADCCON, 0);
@@ -139,16 +133,9 @@ static int spi_clps711x_probe(struct platform_device *pdev)
        ret = devm_request_irq(&pdev->dev, irq, spi_clps711x_isr, 0,
                               dev_name(&pdev->dev), host);
        if (ret)
-               goto err_out;
+               return ret;
 
-       ret = devm_spi_register_controller(&pdev->dev, host);
-       if (!ret)
-               return 0;
-
-err_out:
-       spi_controller_put(host);
-
-       return ret;
+       return devm_spi_register_controller(&pdev->dev, host);
 }
 
 static const struct of_device_id clps711x_spi_dt_ids[] = {