public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/3] spi: omap2-mcspi: switch to managed controller allocation
@ 2026-04-30 12:01 Johan Hovold
  2026-04-30 12:01 ` [PATCH v2 1/3] " Johan Hovold
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Johan Hovold @ 2026-04-30 12:01 UTC (permalink / raw)
  To: Mark Brown; +Cc: linux-spi, linux-kernel, Johan Hovold

This series supersedes the omap2-mcspi patch in the managed controller
allocation series. [1]

Included are also two related cleanups.

Johan


[1] https://lore.kernel.org/lkml/20260429091333.165363-1-johan@kernel.org/


Changes in v2:
 - release DMA resources also if DMA setup fails
 - clean up error labels
 - clean up return value


Johan Hovold (3):
  spi: omap2-mcspi: switch to managed controller allocation
  spi: omap2-mcspi: clean up error labels
  spi: omap2-mcspi: clean up probe return value

 drivers/spi/spi-omap2-mcspi.c | 42 +++++++++++++++--------------------
 1 file changed, 18 insertions(+), 24 deletions(-)

-- 
2.53.0


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

* [PATCH v2 1/3] spi: omap2-mcspi: switch to managed controller allocation
  2026-04-30 12:01 [PATCH v2 0/3] spi: omap2-mcspi: switch to managed controller allocation Johan Hovold
@ 2026-04-30 12:01 ` Johan Hovold
  2026-04-30 12:01 ` [PATCH v2 2/3] spi: omap2-mcspi: clean up error labels Johan Hovold
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Johan Hovold @ 2026-04-30 12:01 UTC (permalink / raw)
  To: Mark Brown; +Cc: linux-spi, linux-kernel, Johan Hovold

Switch to device managed controller allocation to simplify error
handling and to avoid having to take another reference during
deregistration.

Signed-off-by: Johan Hovold <johan@kernel.org>
---
 drivers/spi/spi-omap2-mcspi.c | 23 ++++++++---------------
 1 file changed, 8 insertions(+), 15 deletions(-)

diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
index 56b30ff58771..60c05eb91781 100644
--- a/drivers/spi/spi-omap2-mcspi.c
+++ b/drivers/spi/spi-omap2-mcspi.c
@@ -1484,9 +1484,9 @@ static int omap2_mcspi_probe(struct platform_device *pdev)
 	const struct of_device_id *match;
 
 	if (of_property_read_bool(node, "spi-slave"))
-		ctlr = spi_alloc_target(&pdev->dev, sizeof(*mcspi));
+		ctlr = devm_spi_alloc_target(&pdev->dev, sizeof(*mcspi));
 	else
-		ctlr = spi_alloc_host(&pdev->dev, sizeof(*mcspi));
+		ctlr = devm_spi_alloc_host(&pdev->dev, sizeof(*mcspi));
 	if (!ctlr)
 		return -ENOMEM;
 
@@ -1530,10 +1530,9 @@ static int omap2_mcspi_probe(struct platform_device *pdev)
 	}
 
 	mcspi->base = devm_platform_get_and_ioremap_resource(pdev, 0, &r);
-	if (IS_ERR(mcspi->base)) {
-		status = PTR_ERR(mcspi->base);
-		goto free_ctlr;
-	}
+	if (IS_ERR(mcspi->base))
+		return PTR_ERR(mcspi->base);
+
 	mcspi->phys = r->start + regs_offset;
 	mcspi->base += regs_offset;
 
@@ -1544,10 +1543,8 @@ static int omap2_mcspi_probe(struct platform_device *pdev)
 	mcspi->dma_channels = devm_kcalloc(&pdev->dev, ctlr->num_chipselect,
 					   sizeof(struct omap2_mcspi_dma),
 					   GFP_KERNEL);
-	if (mcspi->dma_channels == NULL) {
-		status = -ENOMEM;
-		goto free_ctlr;
-	}
+	if (mcspi->dma_channels == NULL)
+		return -ENOMEM;
 
 	for (i = 0; i < ctlr->num_chipselect; i++) {
 		sprintf(mcspi->dma_channels[i].dma_rx_ch_name, "rx%d", i);
@@ -1604,7 +1601,7 @@ static int omap2_mcspi_probe(struct platform_device *pdev)
 	pm_runtime_disable(&pdev->dev);
 free_ctlr:
 	omap2_mcspi_release_dma(ctlr);
-	spi_controller_put(ctlr);
+
 	return status;
 }
 
@@ -1613,8 +1610,6 @@ static void omap2_mcspi_remove(struct platform_device *pdev)
 	struct spi_controller *ctlr = platform_get_drvdata(pdev);
 	struct omap2_mcspi *mcspi = spi_controller_get_devdata(ctlr);
 
-	spi_controller_get(ctlr);
-
 	spi_unregister_controller(ctlr);
 
 	omap2_mcspi_release_dma(ctlr);
@@ -1622,8 +1617,6 @@ static void omap2_mcspi_remove(struct platform_device *pdev)
 	pm_runtime_dont_use_autosuspend(mcspi->dev);
 	pm_runtime_put_sync(mcspi->dev);
 	pm_runtime_disable(&pdev->dev);
-
-	spi_controller_put(ctlr);
 }
 
 /* work with hotplug and coldplug */
-- 
2.53.0


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

* [PATCH v2 2/3] spi: omap2-mcspi: clean up error labels
  2026-04-30 12:01 [PATCH v2 0/3] spi: omap2-mcspi: switch to managed controller allocation Johan Hovold
  2026-04-30 12:01 ` [PATCH v2 1/3] " Johan Hovold
@ 2026-04-30 12:01 ` Johan Hovold
  2026-04-30 12:02 ` [PATCH v2 3/3] spi: omap2-mcspi: clean up probe return value Johan Hovold
  2026-05-04 13:12 ` [PATCH v2 0/3] spi: omap2-mcspi: switch to managed controller allocation Mark Brown
  3 siblings, 0 replies; 5+ messages in thread
From: Johan Hovold @ 2026-04-30 12:01 UTC (permalink / raw)
  To: Mark Brown; +Cc: linux-spi, linux-kernel, Johan Hovold

Clean up the error labels by adding a common prefix and naming them
after what they do.

Signed-off-by: Johan Hovold <johan@kernel.org>
---
 drivers/spi/spi-omap2-mcspi.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
index 60c05eb91781..59ebdf7edbd2 100644
--- a/drivers/spi/spi-omap2-mcspi.c
+++ b/drivers/spi/spi-omap2-mcspi.c
@@ -1553,26 +1553,27 @@ static int omap2_mcspi_probe(struct platform_device *pdev)
 		status = omap2_mcspi_request_dma(mcspi,
 						 &mcspi->dma_channels[i]);
 		if (status == -EPROBE_DEFER)
-			goto free_ctlr;
+			goto err_release_dma;
 	}
 
 	status = platform_get_irq(pdev, 0);
 	if (status < 0)
-		goto free_ctlr;
+		goto err_release_dma;
+
 	init_completion(&mcspi->txdone);
 	status = devm_request_irq(&pdev->dev, status,
 				  omap2_mcspi_irq_handler, 0, pdev->name,
 				  mcspi);
 	if (status) {
 		dev_err(&pdev->dev, "Cannot request IRQ");
-		goto free_ctlr;
+		goto err_release_dma;
 	}
 
 	mcspi->ref_clk = devm_clk_get_optional_enabled(&pdev->dev, NULL);
 	if (IS_ERR(mcspi->ref_clk)) {
 		status = PTR_ERR(mcspi->ref_clk);
 		dev_err_probe(&pdev->dev, status, "Failed to get ref_clk");
-		goto free_ctlr;
+		goto err_release_dma;
 	}
 	if (mcspi->ref_clk)
 		mcspi->ref_clk_hz = clk_get_rate(mcspi->ref_clk);
@@ -1587,19 +1588,19 @@ static int omap2_mcspi_probe(struct platform_device *pdev)
 
 	status = omap2_mcspi_controller_setup(mcspi);
 	if (status < 0)
-		goto disable_pm;
+		goto err_disable_rpm;
 
 	status = spi_register_controller(ctlr);
 	if (status < 0)
-		goto disable_pm;
+		goto err_disable_rpm;
 
 	return status;
 
-disable_pm:
+err_disable_rpm:
 	pm_runtime_dont_use_autosuspend(&pdev->dev);
 	pm_runtime_put_sync(&pdev->dev);
 	pm_runtime_disable(&pdev->dev);
-free_ctlr:
+err_release_dma:
 	omap2_mcspi_release_dma(ctlr);
 
 	return status;
-- 
2.53.0


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

* [PATCH v2 3/3] spi: omap2-mcspi: clean up probe return value
  2026-04-30 12:01 [PATCH v2 0/3] spi: omap2-mcspi: switch to managed controller allocation Johan Hovold
  2026-04-30 12:01 ` [PATCH v2 1/3] " Johan Hovold
  2026-04-30 12:01 ` [PATCH v2 2/3] spi: omap2-mcspi: clean up error labels Johan Hovold
@ 2026-04-30 12:02 ` Johan Hovold
  2026-05-04 13:12 ` [PATCH v2 0/3] spi: omap2-mcspi: switch to managed controller allocation Mark Brown
  3 siblings, 0 replies; 5+ messages in thread
From: Johan Hovold @ 2026-04-30 12:02 UTC (permalink / raw)
  To: Mark Brown; +Cc: linux-spi, linux-kernel, Johan Hovold

Return explicit zero on successful probe to clearly separate the success
and error paths and make the code more readable.

Signed-off-by: Johan Hovold <johan@kernel.org>
---
 drivers/spi/spi-omap2-mcspi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
index 59ebdf7edbd2..d53f98aa0aac 100644
--- a/drivers/spi/spi-omap2-mcspi.c
+++ b/drivers/spi/spi-omap2-mcspi.c
@@ -1594,7 +1594,7 @@ static int omap2_mcspi_probe(struct platform_device *pdev)
 	if (status < 0)
 		goto err_disable_rpm;
 
-	return status;
+	return 0;
 
 err_disable_rpm:
 	pm_runtime_dont_use_autosuspend(&pdev->dev);
-- 
2.53.0


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

* Re: [PATCH v2 0/3] spi: omap2-mcspi: switch to managed controller allocation
  2026-04-30 12:01 [PATCH v2 0/3] spi: omap2-mcspi: switch to managed controller allocation Johan Hovold
                   ` (2 preceding siblings ...)
  2026-04-30 12:02 ` [PATCH v2 3/3] spi: omap2-mcspi: clean up probe return value Johan Hovold
@ 2026-05-04 13:12 ` Mark Brown
  3 siblings, 0 replies; 5+ messages in thread
From: Mark Brown @ 2026-05-04 13:12 UTC (permalink / raw)
  To: Johan Hovold; +Cc: linux-spi, linux-kernel

On Thu, 30 Apr 2026 14:01:57 +0200, Johan Hovold wrote:
> spi: omap2-mcspi: switch to managed controller allocation
> 
> This series supersedes the omap2-mcspi patch in the managed controller
> allocation series. [1]
> 
> Included are also two related cleanups.
> 
> [...]

Applied to

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

Thanks!

[1/3] spi: omap2-mcspi: switch to managed controller allocation
      https://git.kernel.org/broonie/spi/c/caf2fd997bf3
[2/3] spi: omap2-mcspi: clean up error labels
      https://git.kernel.org/broonie/spi/c/186fda6ee1ac
[3/3] spi: omap2-mcspi: clean up probe return value
      https://git.kernel.org/broonie/spi/c/46bd1fafc494

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] 5+ messages in thread

end of thread, other threads:[~2026-05-05  1:09 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-30 12:01 [PATCH v2 0/3] spi: omap2-mcspi: switch to managed controller allocation Johan Hovold
2026-04-30 12:01 ` [PATCH v2 1/3] " Johan Hovold
2026-04-30 12:01 ` [PATCH v2 2/3] spi: omap2-mcspi: clean up error labels Johan Hovold
2026-04-30 12:02 ` [PATCH v2 3/3] spi: omap2-mcspi: clean up probe return value Johan Hovold
2026-05-04 13:12 ` [PATCH v2 0/3] spi: omap2-mcspi: switch to managed controller allocation Mark Brown

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