]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
spi: altera-platform: switch to managed controller allocation
authorJohan Hovold <johan@kernel.org>
Mon, 11 May 2026 15:03:57 +0000 (17:03 +0200)
committerMark Brown <broonie@kernel.org>
Mon, 18 May 2026 09:19:41 +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-2-johan@kernel.org
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/spi/spi-altera-platform.c

index fc81de2610ef5da17fced27a66c21d8412d90ba1..3ee5d3480bb46f4fd0dd4dbed3402d31e26b9103 100644 (file)
@@ -39,12 +39,12 @@ static int altera_spi_probe(struct platform_device *pdev)
        enum altera_spi_type type = ALTERA_SPI_TYPE_UNKNOWN;
        struct altera_spi *hw;
        struct spi_controller *host;
-       int err = -ENODEV;
+       int err;
        u16 i;
 
-       host = spi_alloc_host(&pdev->dev, sizeof(struct altera_spi));
+       host = devm_spi_alloc_host(&pdev->dev, sizeof(struct altera_spi));
        if (!host)
-               return err;
+               return -ENOMEM;
 
        /* setup the host state. */
        host->bus_num = -1;
@@ -54,8 +54,7 @@ static int altera_spi_probe(struct platform_device *pdev)
                        dev_err(&pdev->dev,
                                "Invalid number of chipselect: %u\n",
                                pdata->num_chipselect);
-                       err = -EINVAL;
-                       goto exit;
+                       return -EINVAL;
                }
 
                host->num_chipselect = pdata->num_chipselect;
@@ -80,7 +79,7 @@ static int altera_spi_probe(struct platform_device *pdev)
                hw->regmap = dev_get_regmap(pdev->dev.parent, NULL);
                if (!hw->regmap) {
                        dev_err(&pdev->dev, "get regmap failed\n");
-                       goto exit;
+                       return -ENODEV;
                }
 
                regoff = platform_get_resource(pdev, IORESOURCE_REG, 0);
@@ -90,17 +89,14 @@ static int altera_spi_probe(struct platform_device *pdev)
                void __iomem *res;
 
                res = devm_platform_ioremap_resource(pdev, 0);
-               if (IS_ERR(res)) {
-                       err = PTR_ERR(res);
-                       goto exit;
-               }
+               if (IS_ERR(res))
+                       return PTR_ERR(res);
 
                hw->regmap = devm_regmap_init_mmio(&pdev->dev, res,
                                                   &spi_altera_config);
                if (IS_ERR(hw->regmap)) {
                        dev_err(&pdev->dev, "regmap mmio init failed\n");
-                       err = PTR_ERR(hw->regmap);
-                       goto exit;
+                       return PTR_ERR(hw->regmap);
                }
        }
 
@@ -112,12 +108,12 @@ static int altera_spi_probe(struct platform_device *pdev)
                err = devm_request_irq(&pdev->dev, hw->irq, altera_spi_irq, 0,
                                       pdev->name, host);
                if (err)
-                       goto exit;
+                       return err;
        }
 
        err = devm_spi_register_controller(&pdev->dev, host);
        if (err)
-               goto exit;
+               return err;
 
        if (pdata) {
                for (i = 0; i < pdata->num_devices; i++) {
@@ -131,9 +127,6 @@ static int altera_spi_probe(struct platform_device *pdev)
        dev_info(&pdev->dev, "regoff %u, irq %d\n", hw->regoff, hw->irq);
 
        return 0;
-exit:
-       spi_controller_put(host);
-       return err;
 }
 
 #ifdef CONFIG_OF