[PATCH 01/12] spi: altera-platform: switch to managed controller allocation
From: Johan Hovold
Date: Mon May 11 2026 - 11:35:02 EST
Switch to device managed controller allocation for consistency and to
simplify error handling.
Signed-off-by: Johan Hovold <johan@xxxxxxxxxx>
---
drivers/spi/spi-altera-platform.c | 27 ++++++++++-----------------
1 file changed, 10 insertions(+), 17 deletions(-)
diff --git a/drivers/spi/spi-altera-platform.c b/drivers/spi/spi-altera-platform.c
index fc81de2610ef..3ee5d3480bb4 100644
--- a/drivers/spi/spi-altera-platform.c
+++ b/drivers/spi/spi-altera-platform.c
@@ -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
--
2.53.0