From: Johan Hovold <johan@kernel.org>
To: Mark Brown <broonie@kernel.org>
Cc: Eddie James <eajames@linux.ibm.com>,
Yang Shen <shenyang39@huawei.com>,
Neil Armstrong <neil.armstrong@linaro.org>,
Kevin Hilman <khilman@baylibre.com>,
linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org,
Johan Hovold <johan@kernel.org>
Subject: [PATCH 01/12] spi: altera-platform: switch to managed controller allocation
Date: Mon, 11 May 2026 17:03:57 +0200 [thread overview]
Message-ID: <20260511150408.796155-2-johan@kernel.org> (raw)
In-Reply-To: <20260511150408.796155-1-johan@kernel.org>
Switch to device managed controller allocation for consistency and to
simplify error handling.
Signed-off-by: Johan Hovold <johan@kernel.org>
---
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
next prev parent reply other threads:[~2026-05-11 15:04 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-11 15:03 [PATCH 00/12] spi: switch to managed controller allocation (part 3/3) Johan Hovold
2026-05-11 15:03 ` Johan Hovold [this message]
2026-05-11 15:03 ` [PATCH 02/12] spi: armada-3700: switch to managed controller allocation Johan Hovold
2026-05-11 15:03 ` [PATCH 03/12] spi: clps711x: " Johan Hovold
2026-05-11 15:04 ` [PATCH 04/12] spi: falcon: " Johan Hovold
2026-05-11 15:04 ` [PATCH 05/12] spi: fsi: " Johan Hovold
2026-05-11 15:04 ` [PATCH 06/12] spi: hisi-sfc-v3xx: " Johan Hovold
2026-05-11 15:04 ` [PATCH 07/12] spi: jcore: " Johan Hovold
2026-05-11 15:04 ` [PATCH 08/12] spi: lp8841-rtc: " Johan Hovold
2026-05-11 15:04 ` [PATCH 09/12] spi: lp8841-rtc: drop unused ifdef Johan Hovold
2026-05-11 15:04 ` [PATCH 10/12] spi: meson-spifc: switch to managed controller allocation Johan Hovold
2026-05-11 15:04 ` [PATCH 11/12] spi: mux: " Johan Hovold
2026-05-11 15:04 ` [PATCH 12/12] spi: xlp: " Johan Hovold
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260511150408.796155-2-johan@kernel.org \
--to=johan@kernel.org \
--cc=broonie@kernel.org \
--cc=eajames@linux.ibm.com \
--cc=khilman@baylibre.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-spi@vger.kernel.org \
--cc=neil.armstrong@linaro.org \
--cc=shenyang39@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox