mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] spi: ath79: use devm everywhere in probe
@ 2026-07-27 20:15 Rosen Penev
  2026-08-04 23:12 ` Mark Brown
  0 siblings, 1 reply; 2+ messages in thread
From: Rosen Penev @ 2026-07-27 20:15 UTC (permalink / raw)
  To: linux-spi; +Cc: Mark Brown, open list

Use devm_spi_alloc_host() instead of spi_alloc_host() so that the spi
controller is automatically freed on probe failure or device removal.
This lets us eliminate the err_put_host label and goto error path in
probe, as well as the spi_controller_put() call in remove.

It's also a bit weird as everything in probe is using devm except the
first allocating function. Might fix an ordering issue on teardown.

Assisted-by: opencode:big-pickle
Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
 drivers/spi/spi-ath79.c | 24 +++++++-----------------
 1 file changed, 7 insertions(+), 17 deletions(-)

diff --git a/drivers/spi/spi-ath79.c b/drivers/spi/spi-ath79.c
index 2f61e5b9943c..1f5d0fb03917 100644
--- a/drivers/spi/spi-ath79.c
+++ b/drivers/spi/spi-ath79.c
@@ -173,7 +173,7 @@ static int ath79_spi_probe(struct platform_device *pdev)
 	unsigned long rate;
 	int ret;
 
-	host = spi_alloc_host(&pdev->dev, sizeof(*sp));
+	host = devm_spi_alloc_host(&pdev->dev, sizeof(*sp));
 	if (host == NULL) {
 		dev_err(&pdev->dev, "failed to allocate spi host\n");
 		return -ENOMEM;
@@ -194,22 +194,16 @@ static int ath79_spi_probe(struct platform_device *pdev)
 	sp->bitbang.flags = SPI_CS_HIGH;
 
 	sp->base = devm_platform_ioremap_resource(pdev, 0);
-	if (IS_ERR(sp->base)) {
-		ret = PTR_ERR(sp->base);
-		goto err_put_host;
-	}
+	if (IS_ERR(sp->base))
+		return PTR_ERR(sp->base);
 
 	sp->clk = devm_clk_get_enabled(&pdev->dev, "ahb");
-	if (IS_ERR(sp->clk)) {
-		ret = PTR_ERR(sp->clk);
-		goto err_put_host;
-	}
+	if (IS_ERR(sp->clk))
+		return PTR_ERR(sp->clk);
 
 	rate = DIV_ROUND_UP(clk_get_rate(sp->clk), MHZ);
-	if (!rate) {
-		ret = -EINVAL;
-		goto err_put_host;
-	}
+	if (!rate)
+		return -EINVAL;
 
 	sp->rrw_delay = ATH79_SPI_RRW_DELAY_FACTOR / rate;
 	dev_dbg(&pdev->dev, "register read/write delay is %u nsecs\n",
@@ -224,9 +218,6 @@ static int ath79_spi_probe(struct platform_device *pdev)
 
 err_disable:
 	ath79_spi_disable(sp);
-err_put_host:
-	spi_controller_put(host);
-
 	return ret;
 }
 
@@ -236,7 +227,6 @@ static void ath79_spi_remove(struct platform_device *pdev)
 
 	spi_bitbang_stop(&sp->bitbang);
 	ath79_spi_disable(sp);
-	spi_controller_put(sp->bitbang.ctlr);
 }
 
 static void ath79_spi_shutdown(struct platform_device *pdev)
-- 
2.55.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] spi: ath79: use devm everywhere in probe
  2026-07-27 20:15 [PATCH] spi: ath79: use devm everywhere in probe Rosen Penev
@ 2026-08-04 23:12 ` Mark Brown
  0 siblings, 0 replies; 2+ messages in thread
From: Mark Brown @ 2026-08-04 23:12 UTC (permalink / raw)
  To: linux-spi, Rosen Penev; +Cc: linux-kernel

On Mon, 27 Jul 2026 13:15:43 -0700, Rosen Penev wrote:
> spi: ath79: use devm everywhere in probe

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-7.3

Thanks!

[1/1] spi: ath79: use devm everywhere in probe
      https://git.kernel.org/broonie/spi/c/362a11ef1bea

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-08-05 10:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-07-27 20:15 [PATCH] spi: ath79: use devm everywhere in probe Rosen Penev
2026-08-04 23:12 ` Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®