Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/4]  ASoC: atmel: mchp-spdifrx: Improve driver cleanup and error handling
@ 2026-11-19 10:34 phucduc.bui
  2026-11-19 10:34 ` [PATCH 1/4] ASoC: atmel: mchp-spdifrx: Improve probe " phucduc.bui
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: phucduc.bui @ 2026-11-19 10:34 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 runtime PM cleanup, 
adjusts IRQ registration order, and fixes error propagation in the 
ulock get callback.

Compile-tested only.

Best regards,
Phuc

bui duc phuc (4):
  ASoC: atmel: mchp-spdifrx: Improve probe error handling
  ASoC: atmel: mchp-spdifrx: Use devm helpers for runtime PM
  ASoC: atmel: mchp-spdifrx: Move IRQ request after runtime PM setup
  ASoC: atmel: mchp-spdifrx: Propagate runtime PM errors in ulock get

 sound/soc/atmel/mchp-spdifrx.c | 81 ++++++++++++++++------------------
 1 file changed, 39 insertions(+), 42 deletions(-)

-- 
2.43.0



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

* [PATCH 1/4] ASoC: atmel: mchp-spdifrx: Improve probe error handling
  2026-11-19 10:34 [PATCH 0/4] ASoC: atmel: mchp-spdifrx: Improve driver cleanup and error handling phucduc.bui
@ 2026-11-19 10:34 ` phucduc.bui
  2026-11-19 10:34 ` [PATCH 2/4] ASoC: atmel: mchp-spdifrx: Use devm helpers for runtime PM phucduc.bui
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: phucduc.bui @ 2026-11-19 10:34 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-spdifrx.c | 18 ++++++------------
 1 file changed, 6 insertions(+), 12 deletions(-)

diff --git a/sound/soc/atmel/mchp-spdifrx.c b/sound/soc/atmel/mchp-spdifrx.c
index 63089ac3ebdc..7d80f35576cd 100644
--- a/sound/soc/atmel/mchp-spdifrx.c
+++ b/sound/soc/atmel/mchp-spdifrx.c
@@ -1116,21 +1116,15 @@ static int mchp_spdifrx_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 generated 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 generated 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 generated clock\n");
 
 	/*
 	 * Signal control need a valid rate on gclk. hw_params() configures
-- 
2.43.0



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

* [PATCH 2/4] ASoC: atmel: mchp-spdifrx: Use devm helpers for runtime PM
  2026-11-19 10:34 [PATCH 0/4] ASoC: atmel: mchp-spdifrx: Improve driver cleanup and error handling phucduc.bui
  2026-11-19 10:34 ` [PATCH 1/4] ASoC: atmel: mchp-spdifrx: Improve probe " phucduc.bui
@ 2026-11-19 10:34 ` phucduc.bui
  2026-11-19 10:34 ` [PATCH 3/4] ASoC: atmel: mchp-spdifrx: Move IRQ request after runtime PM setup phucduc.bui
  2026-11-19 10:34 ` [PATCH 4/4] ASoC: atmel: mchp-spdifrx: Propagate runtime PM errors in ulock get phucduc.bui
  3 siblings, 0 replies; 5+ messages in thread
From: phucduc.bui @ 2026-11-19 10:34 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-spdifrx.c | 47 ++++++++++++++++++----------------
 1 file changed, 25 insertions(+), 22 deletions(-)

diff --git a/sound/soc/atmel/mchp-spdifrx.c b/sound/soc/atmel/mchp-spdifrx.c
index 7d80f35576cd..25122f6ef3c9 100644
--- a/sound/soc/atmel/mchp-spdifrx.c
+++ b/sound/soc/atmel/mchp-spdifrx.c
@@ -1079,6 +1079,15 @@ static const struct dev_pm_ops mchp_spdifrx_pm_ops = {
 		       NULL)
 };
 
+/* Runtime suspend the device on cleanup if necessary */
+static void mchp_spdifrx_runtime_suspend_action(void *data)
+{
+	struct device *dev = data;
+
+	if (!pm_runtime_status_suspended(dev))
+		mchp_spdifrx_runtime_suspend(dev);
+}
+
 static int mchp_spdifrx_probe(struct platform_device *pdev)
 {
 	struct mchp_spdifrx_dev *dev;
@@ -1141,11 +1150,22 @@ static int mchp_spdifrx_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_spdifrx_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_spdifrx_runtime_resume(dev->dev);
-		if (err)
-			goto pm_runtime_disable;
+		if (err) {
+			devm_remove_action(dev->dev,
+					   mchp_spdifrx_runtime_suspend_action,
+					   dev->dev);
+			return err;
+		}
 	}
 
 	dev->capture.addr	= (dma_addr_t)mem->start + SPDIFRX_RHR;
@@ -1154,7 +1174,7 @@ static int mchp_spdifrx_probe(struct platform_device *pdev)
 	err = devm_snd_dmaengine_pcm_register(&pdev->dev, NULL, 0);
 	if (err) {
 		dev_err(&pdev->dev, "failed to register PCM: %d\n", err);
-		goto pm_runtime_suspend;
+		return err;
 	}
 
 	err = devm_snd_soc_register_component(&pdev->dev,
@@ -1162,34 +1182,17 @@ static int mchp_spdifrx_probe(struct platform_device *pdev)
 					      &mchp_spdifrx_dai, 1);
 	if (err) {
 		dev_err(&pdev->dev, "fail to register dai\n");
-		goto pm_runtime_suspend;
+		return err;
 	}
 
 	regmap_read(regmap, SPDIFRX_VERSION, &vers);
 	dev_info(&pdev->dev, "hw version: %#lx\n", vers & SPDIFRX_VERSION_MASK);
 
 	return 0;
-
-pm_runtime_suspend:
-	if (!pm_runtime_status_suspended(dev->dev))
-		mchp_spdifrx_runtime_suspend(dev->dev);
-pm_runtime_disable:
-	pm_runtime_disable(dev->dev);
-	return err;
-}
-
-static void mchp_spdifrx_remove(struct platform_device *pdev)
-{
-	struct mchp_spdifrx_dev *dev = platform_get_drvdata(pdev);
-
-	pm_runtime_disable(dev->dev);
-	if (!pm_runtime_status_suspended(dev->dev))
-		mchp_spdifrx_runtime_suspend(dev->dev);
 }
 
 static struct platform_driver mchp_spdifrx_driver = {
 	.probe	= mchp_spdifrx_probe,
-	.remove = mchp_spdifrx_remove,
 	.driver	= {
 		.name	= "mchp_spdifrx",
 		.of_match_table = mchp_spdifrx_dt_ids,
-- 
2.43.0



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

* [PATCH 3/4] ASoC: atmel: mchp-spdifrx: Move IRQ request after runtime PM setup
  2026-11-19 10:34 [PATCH 0/4] ASoC: atmel: mchp-spdifrx: Improve driver cleanup and error handling phucduc.bui
  2026-11-19 10:34 ` [PATCH 1/4] ASoC: atmel: mchp-spdifrx: Improve probe " phucduc.bui
  2026-11-19 10:34 ` [PATCH 2/4] ASoC: atmel: mchp-spdifrx: Use devm helpers for runtime PM phucduc.bui
@ 2026-11-19 10:34 ` phucduc.bui
  2026-11-19 10:34 ` [PATCH 4/4] ASoC: atmel: mchp-spdifrx: Propagate runtime PM errors in ulock get phucduc.bui
  3 siblings, 0 replies; 5+ messages in thread
From: phucduc.bui @ 2026-11-19 10:34 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-spdifrx.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/sound/soc/atmel/mchp-spdifrx.c b/sound/soc/atmel/mchp-spdifrx.c
index 25122f6ef3c9..41c65e835765 100644
--- a/sound/soc/atmel/mchp-spdifrx.c
+++ b/sound/soc/atmel/mchp-spdifrx.c
@@ -1113,16 +1113,11 @@ static int mchp_spdifrx_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_spdif_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))
@@ -1168,6 +1163,12 @@ static int mchp_spdifrx_probe(struct platform_device *pdev)
 		}
 	}
 
+	/* Request IRQ. */
+	err = devm_request_irq(&pdev->dev, irq, mchp_spdif_interrupt, 0,
+			       dev_name(&pdev->dev), dev);
+	if (err)
+		return err;
+
 	dev->capture.addr	= (dma_addr_t)mem->start + SPDIFRX_RHR;
 	dev->capture.maxburst	= 1;
 
-- 
2.43.0



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

* [PATCH 4/4] ASoC: atmel: mchp-spdifrx: Propagate runtime PM errors in ulock get
  2026-11-19 10:34 [PATCH 0/4] ASoC: atmel: mchp-spdifrx: Improve driver cleanup and error handling phucduc.bui
                   ` (2 preceding siblings ...)
  2026-11-19 10:34 ` [PATCH 3/4] ASoC: atmel: mchp-spdifrx: Move IRQ request after runtime PM setup phucduc.bui
@ 2026-11-19 10:34 ` phucduc.bui
  3 siblings, 0 replies; 5+ messages in thread
From: phucduc.bui @ 2026-11-19 10:34 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>

Return the result of pm_runtime_resume_and_get() instead of
comparing the old and current ulock values.

This ensures runtime PM errors are propagated to the caller.

Fixes: c7db2a594389 ("ASoC: mchp-spdifrx: add runtime pm support")
Signed-off-by: bui duc phuc <phucduc.bui@gmail.com>
---
 sound/soc/atmel/mchp-spdifrx.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/sound/soc/atmel/mchp-spdifrx.c b/sound/soc/atmel/mchp-spdifrx.c
index 41c65e835765..632da8d7bc81 100644
--- a/sound/soc/atmel/mchp-spdifrx.c
+++ b/sound/soc/atmel/mchp-spdifrx.c
@@ -709,7 +709,6 @@ static int mchp_spdifrx_ulock_get(struct snd_kcontrol *kcontrol,
 	struct mchp_spdifrx_mixer_control *ctrl = &dev->control;
 	u32 val;
 	int ret;
-	bool ulock_old = ctrl->ulock;
 
 	mutex_lock(&dev->mlock);
 
@@ -735,7 +734,7 @@ static int mchp_spdifrx_ulock_get(struct snd_kcontrol *kcontrol,
 unlock:
 	mutex_unlock(&dev->mlock);
 
-	return ulock_old != ctrl->ulock;
+	return ret;
 }
 
 static int mchp_spdifrx_badf_get(struct snd_kcontrol *kcontrol,
-- 
2.43.0



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

end of thread, other threads:[~2026-11-19 10:35 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-19 10:34 [PATCH 0/4] ASoC: atmel: mchp-spdifrx: Improve driver cleanup and error handling phucduc.bui
2026-11-19 10:34 ` [PATCH 1/4] ASoC: atmel: mchp-spdifrx: Improve probe " phucduc.bui
2026-11-19 10:34 ` [PATCH 2/4] ASoC: atmel: mchp-spdifrx: Use devm helpers for runtime PM phucduc.bui
2026-11-19 10:34 ` [PATCH 3/4] ASoC: atmel: mchp-spdifrx: Move IRQ request after runtime PM setup phucduc.bui
2026-11-19 10:34 ` [PATCH 4/4] ASoC: atmel: mchp-spdifrx: Propagate runtime PM errors in ulock get phucduc.bui

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