mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/3] ASoC: atmel: mchp-spdiftx: Improve probe and PM handling
@ 2026-11-20  9:43 phucduc.bui
  2026-11-20  9:43 ` [PATCH 1/3] ASoC: atmel: mchp-spdiftx: Improve probe error handling phucduc.bui
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: phucduc.bui @ 2026-11-20  9:43 UTC (permalink / raw)
  To: Mark Brown, Claudiu Beznea, Andrei Simion, Nicolas Ferre,
	Alexandre Belloni
  Cc: Liam Girdwood, Jaroslav Kysela, Takashi Iwai, linux-sound,
	linux-arm-kernel, linux-kernel, bui duc phuc

From: bui duc phuc <phucduc.bui@gmail.com>

Hi all,

This series improves probe error handling and simplifies runtime PM 
management in the mchp-spdiftx driver. It also moves IRQ registration 
after runtime PM setup.

Compile-tested only.

Best regards,
Phuc

bui duc phuc (3):
  ASoC: atmel: mchp-spdiftx: Improve probe error handling
  ASoC: atmel: mchp-spdiftx: Use devm helpers for runtime PM
  ASoC: atmel: mchp-spdiftx: Move IRQ request after runtime PM setup

 sound/soc/atmel/mchp-spdiftx.c | 77 ++++++++++++++++------------------
 1 file changed, 37 insertions(+), 40 deletions(-)

-- 
2.43.0


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

* [PATCH 1/3] ASoC: atmel: mchp-spdiftx: Improve probe error handling
  2026-11-20  9:43 [PATCH 0/3] ASoC: atmel: mchp-spdiftx: Improve probe and PM handling phucduc.bui
@ 2026-11-20  9:43 ` phucduc.bui
  2026-11-20  9:43 ` [PATCH 2/3] ASoC: atmel: mchp-spdiftx: Use devm helpers for runtime PM phucduc.bui
  2026-11-20  9:43 ` [PATCH 3/3] ASoC: atmel: mchp-spdiftx: Move IRQ request after runtime PM setup phucduc.bui
  2 siblings, 0 replies; 4+ messages in thread
From: phucduc.bui @ 2026-11-20  9:43 UTC (permalink / raw)
  To: Mark Brown, Claudiu Beznea, Andrei Simion, Nicolas Ferre,
	Alexandre Belloni
  Cc: Liam Girdwood, Jaroslav Kysela, Takashi Iwai, linux-sound,
	linux-arm-kernel, linux-kernel, bui duc phuc

From: bui duc phuc <phucduc.bui@gmail.com>

Use dev_err_probe() when retrieving clocks to avoid logging errors
for deferred probes.

Signed-off-by: bui duc phuc <phucduc.bui@gmail.com>
---
 sound/soc/atmel/mchp-spdiftx.c | 18 ++++++------------
 1 file changed, 6 insertions(+), 12 deletions(-)

diff --git a/sound/soc/atmel/mchp-spdiftx.c b/sound/soc/atmel/mchp-spdiftx.c
index fc635ed6856e..6ab32f0b8b8e 100644
--- a/sound/soc/atmel/mchp-spdiftx.c
+++ b/sound/soc/atmel/mchp-spdiftx.c
@@ -815,21 +815,15 @@ static int mchp_spdiftx_probe(struct platform_device *pdev)
 
 	/* Get the peripheral clock */
 	dev->pclk = devm_clk_get(&pdev->dev, "pclk");
-	if (IS_ERR(dev->pclk)) {
-		err = PTR_ERR(dev->pclk);
-		dev_err(&pdev->dev,
-			"failed to get the peripheral clock: %d\n", err);
-		return err;
-	}
+	if (IS_ERR(dev->pclk))
+		return dev_err_probe(&pdev->dev, PTR_ERR(dev->pclk),
+				     "failed to get the peripheral clock\n");
 
 	/* Get the generic clock */
 	dev->gclk = devm_clk_get(&pdev->dev, "gclk");
-	if (IS_ERR(dev->gclk)) {
-		err = PTR_ERR(dev->gclk);
-		dev_err(&pdev->dev,
-			"failed to get the PMC generic clock: %d\n", err);
-		return err;
-	}
+	if (IS_ERR(dev->gclk))
+		return dev_err_probe(&pdev->dev, PTR_ERR(dev->gclk),
+				     "failed to get the PMC generic clock\n");
 
 	ctrl = &dev->control;
 	spin_lock_init(&ctrl->lock);
-- 
2.43.0


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

* [PATCH 2/3] ASoC: atmel: mchp-spdiftx: Use devm helpers for runtime PM
  2026-11-20  9:43 [PATCH 0/3] ASoC: atmel: mchp-spdiftx: Improve probe and PM handling phucduc.bui
  2026-11-20  9:43 ` [PATCH 1/3] ASoC: atmel: mchp-spdiftx: Improve probe error handling phucduc.bui
@ 2026-11-20  9:43 ` phucduc.bui
  2026-11-20  9:43 ` [PATCH 3/3] ASoC: atmel: mchp-spdiftx: Move IRQ request after runtime PM setup phucduc.bui
  2 siblings, 0 replies; 4+ messages in thread
From: phucduc.bui @ 2026-11-20  9:43 UTC (permalink / raw)
  To: Mark Brown, Claudiu Beznea, Andrei Simion, Nicolas Ferre,
	Alexandre Belloni
  Cc: Liam Girdwood, Jaroslav Kysela, Takashi Iwai, linux-sound,
	linux-arm-kernel, linux-kernel, bui duc phuc

From: bui duc phuc <phucduc.bui@gmail.com>

Use devm_pm_runtime_enable() and a devm action to handle runtime PM
cleanup automatically.

This removes the manual runtime PM cleanup from the probe error
paths and the remove callback.

Signed-off-by: bui duc phuc <phucduc.bui@gmail.com>
---
 sound/soc/atmel/mchp-spdiftx.c | 46 ++++++++++++++++++----------------
 1 file changed, 24 insertions(+), 22 deletions(-)

diff --git a/sound/soc/atmel/mchp-spdiftx.c b/sound/soc/atmel/mchp-spdiftx.c
index 6ab32f0b8b8e..b034bd46cd5a 100644
--- a/sound/soc/atmel/mchp-spdiftx.c
+++ b/sound/soc/atmel/mchp-spdiftx.c
@@ -778,6 +778,15 @@ static const struct dev_pm_ops mchp_spdiftx_pm_ops = {
 		       NULL)
 };
 
+/* Runtime suspend the device on cleanup if necessary */
+static void mchp_spdiftx_runtime_suspend_action(void *data)
+{
+	struct device *dev = data;
+
+	if (!pm_runtime_status_suspended(dev))
+		mchp_spdiftx_runtime_suspend(dev);
+}
+
 static int mchp_spdiftx_probe(struct platform_device *pdev)
 {
 	struct mchp_spdiftx_dev *dev;
@@ -836,11 +845,22 @@ static int mchp_spdiftx_probe(struct platform_device *pdev)
 	dev->regmap = regmap;
 	platform_set_drvdata(pdev, dev);
 
-	pm_runtime_enable(dev->dev);
+	err = devm_add_action(dev->dev, mchp_spdiftx_runtime_suspend_action,
+			      dev->dev);
+	if (err)
+		return err;
+
+	err = devm_pm_runtime_enable(dev->dev);
+	if (err)
+		return err;
 	if (!pm_runtime_enabled(dev->dev)) {
 		err = mchp_spdiftx_runtime_resume(dev->dev);
-		if (err)
+		if (err) {
+			devm_remove_action(dev->dev,
+					   mchp_spdiftx_runtime_suspend_action,
+					   dev->dev);
 			return err;
+		}
 	}
 
 	dev->playback.addr = (dma_addr_t)mem->start + SPDIFTX_CDR;
@@ -849,7 +869,7 @@ static int mchp_spdiftx_probe(struct platform_device *pdev)
 	err = devm_snd_dmaengine_pcm_register(&pdev->dev, NULL, 0);
 	if (err) {
 		dev_err(&pdev->dev, "failed to register PMC: %d\n", err);
-		goto pm_runtime_suspend;
+		return err;
 	}
 
 	err = devm_snd_soc_register_component(&pdev->dev,
@@ -857,32 +877,14 @@ static int mchp_spdiftx_probe(struct platform_device *pdev)
 					      &mchp_spdiftx_dai, 1);
 	if (err) {
 		dev_err(&pdev->dev, "failed to register component: %d\n", err);
-		goto pm_runtime_suspend;
+		return err;
 	}
 
 	return 0;
-
-pm_runtime_suspend:
-	if (!pm_runtime_status_suspended(dev->dev))
-		mchp_spdiftx_runtime_suspend(dev->dev);
-	pm_runtime_disable(dev->dev);
-
-	return err;
-}
-
-static void mchp_spdiftx_remove(struct platform_device *pdev)
-{
-	struct mchp_spdiftx_dev *dev = platform_get_drvdata(pdev);
-
-	if (!pm_runtime_status_suspended(dev->dev))
-		mchp_spdiftx_runtime_suspend(dev->dev);
-
-	pm_runtime_disable(dev->dev);
 }
 
 static struct platform_driver mchp_spdiftx_driver = {
 	.probe	= mchp_spdiftx_probe,
-	.remove = mchp_spdiftx_remove,
 	.driver	= {
 		.name	= "mchp_spdiftx",
 		.of_match_table = mchp_spdiftx_dt_ids,
-- 
2.43.0


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

* [PATCH 3/3] ASoC: atmel: mchp-spdiftx: Move IRQ request after runtime PM setup
  2026-11-20  9:43 [PATCH 0/3] ASoC: atmel: mchp-spdiftx: Improve probe and PM handling phucduc.bui
  2026-11-20  9:43 ` [PATCH 1/3] ASoC: atmel: mchp-spdiftx: Improve probe error handling phucduc.bui
  2026-11-20  9:43 ` [PATCH 2/3] ASoC: atmel: mchp-spdiftx: Use devm helpers for runtime PM phucduc.bui
@ 2026-11-20  9:43 ` phucduc.bui
  2 siblings, 0 replies; 4+ messages in thread
From: phucduc.bui @ 2026-11-20  9:43 UTC (permalink / raw)
  To: Mark Brown, Claudiu Beznea, Andrei Simion, Nicolas Ferre,
	Alexandre Belloni
  Cc: Liam Girdwood, Jaroslav Kysela, Takashi Iwai, linux-sound,
	linux-arm-kernel, linux-kernel, bui duc phuc

From: bui duc phuc <phucduc.bui@gmail.com>

Move devm_request_irq() after runtime PM setup to ensure the IRQ is
released before the runtime suspend action runs during cleanup.

Signed-off-by: bui duc phuc <phucduc.bui@gmail.com>
---
 sound/soc/atmel/mchp-spdiftx.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/sound/soc/atmel/mchp-spdiftx.c b/sound/soc/atmel/mchp-spdiftx.c
index b034bd46cd5a..658ff667439c 100644
--- a/sound/soc/atmel/mchp-spdiftx.c
+++ b/sound/soc/atmel/mchp-spdiftx.c
@@ -812,16 +812,11 @@ static int mchp_spdiftx_probe(struct platform_device *pdev)
 	if (IS_ERR(regmap))
 		return PTR_ERR(regmap);
 
-	/* Request IRQ */
+	/* Get IRQ */
 	irq = platform_get_irq(pdev, 0);
 	if (irq < 0)
 		return irq;
 
-	err = devm_request_irq(&pdev->dev, irq, mchp_spdiftx_interrupt, 0,
-			       dev_name(&pdev->dev), dev);
-	if (err)
-		return err;
-
 	/* Get the peripheral clock */
 	dev->pclk = devm_clk_get(&pdev->dev, "pclk");
 	if (IS_ERR(dev->pclk))
@@ -863,6 +858,12 @@ static int mchp_spdiftx_probe(struct platform_device *pdev)
 		}
 	}
 
+	/* Request IRQ */
+	err = devm_request_irq(&pdev->dev, irq, mchp_spdiftx_interrupt, 0,
+			       dev_name(&pdev->dev), dev);
+	if (err)
+		return err;
+
 	dev->playback.addr = (dma_addr_t)mem->start + SPDIFTX_CDR;
 	dev->playback.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
 
-- 
2.43.0


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

end of thread, other threads:[~2026-11-20  9:44 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-20  9:43 [PATCH 0/3] ASoC: atmel: mchp-spdiftx: Improve probe and PM handling phucduc.bui
2026-11-20  9:43 ` [PATCH 1/3] ASoC: atmel: mchp-spdiftx: Improve probe error handling phucduc.bui
2026-11-20  9:43 ` [PATCH 2/3] ASoC: atmel: mchp-spdiftx: Use devm helpers for runtime PM phucduc.bui
2026-11-20  9:43 ` [PATCH 3/3] ASoC: atmel: mchp-spdiftx: Move IRQ request after runtime PM setup phucduc.bui

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®