Skip to contentSkip to conversation

ASoC: samsung: Improve probe error handling

PATCH Superseded [email protected] 2 participants 13 messages Aug 11 – Aug 12

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover ASoC: samsung: Improve probe error handling

From: bui duc phuc <[email protected]>

Hi all,

This series improves probe error handling in several Samsung ASoC drivers.

Preserve the original error code from gpiod_to_irq() and use dev_err_probe() where appropriate. Also remove redundant probe error messages where the called functions already report the error.

Compile-tested only.

Best regards,
Phuc

bui duc phuc (6):
ASoC: samsung: aries_wm8994: Preserve gpiod_to_irq() error codes
ASoC: samsung: aries_wm8994: Drop redundant probe error messages
ASoC: samsung: pcm: Use dev_err_probe() for error handling
ASoC: samsung: pcm: Drop redundant probe error messages
ASoC: samsung: spdif: Drop redundant probe error messages
ASoC: samsung: tm2_wm5110: Drop redundant probe error messages

 sound/soc/samsung/aries_wm8994.c | 14 ++++----------
 sound/soc/samsung/pcm.c          | 19 +++++++------------
 sound/soc/samsung/spdif.c        |  8 ++------
 sound/soc/samsung/tm2_wm5110.c   | 12 +++---------
 4 files changed, 16 insertions(+), 37 deletions(-)
Signature · 1 line
2.43.0
#1 lore raw

PATCH 1/6 ASoC: samsung: aries_wm8994: Preserve gpiod_to_irq() error codes

From: bui duc phuc <[email protected]>

gpiod_to_irq() can currently return several error codes, including -ENXIO, -ENODEV, -EPROBE_DEFER, and -EINVAL.

Return the original error code instead of overwriting it with -EINVAL, so that the actual failure reason is preserved.

---
 sound/soc/samsung/aries_wm8994.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/samsung/aries_wm8994.c +1 -1
index 6db91b73f25c..58e3e08225de 100644
@@ -374,7 +374,7 @@ static int aries_late_probe(struct snd_soc_card *card)
 	irq = gpiod_to_irq(priv->gpio_headset_detect);
 	if (irq < 0) {
 		dev_err(card->dev, "Failed to map headset detect gpio to irq");
-		return -EINVAL;
+		return irq;
 	}
 
 	ret = devm_request_threaded_irq(card->dev, irq, NULL,
Signature · 1 line
2.43.0
Reviewed-by on v1 1/6
#2 lore raw

Re: [PATCH 1/6] ASoC: samsung: aries_wm8994: Preserve gpiod_to_irq() error codes

Quoted 7 lines · On 8/11/2026 11:05 AM, [email protected] wrote:

From: bui duc phuc <[email protected]>

gpiod_to_irq() can currently return several error codes, including -ENXIO, -ENODEV, -EPROBE_DEFER, and -EINVAL.

Return the original error code instead of overwriting it with -EINVAL, so that the actual failure reason is preserved.

#3 lore raw

PATCH 2/6 ASoC: samsung: aries_wm8994: Drop redundant probe error messages

In reply to [email protected]

From: bui duc phuc <[email protected]>

Remove the probe error messages to avoid duplicate error reporting, since the error is already reported by the called functions.

---
 sound/soc/samsung/aries_wm8994.c | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)
sound/soc/samsung/aries_wm8994.c +3 -9
index 58e3e08225de..d189db96cf17 100644
@@ -381,10 +381,8 @@ static int aries_late_probe(struct snd_soc_card *card)
 			headset_det_irq_thread,
 			IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING |
 			IRQF_ONESHOT, "headset_detect", priv);
-	if (ret) {
-		dev_err(card->dev, "Failed to request headset detect irq");
+	if (ret)
 		return ret;
-	}
 
 	headset_button_gpio[0].data = priv;
 	headset_button_gpio[0].desc = priv->gpio_headset_key;
@@ -623,10 +621,8 @@ static int aries_audio_probe(struct platform_device *pdev)
 	if (ret < 0) {
 		/* Backwards compatible way */
 		ret = snd_soc_of_parse_audio_routing(card, "samsung,audio-routing");
-		if (ret < 0) {
-			dev_err(dev, "Audio routing invalid/unspecified\n");
+		if (ret < 0)
 			return ret;
-		}
 	}
 
 	aries_dai[1].dai_fmt = priv->variant->modem_dai_fmt;
@@ -671,10 +667,8 @@ static int aries_audio_probe(struct platform_device *pdev)
 
 	ret = devm_snd_soc_register_component(dev, &aries_component,
 				aries_ext_dai, ARRAY_SIZE(aries_ext_dai));
-	if (ret < 0) {
-		dev_err(dev, "Failed to register component: %d\n", ret);
+	if (ret < 0)
 		goto out;
-	}
 
 	ret = devm_snd_soc_register_card(dev, card);
 	if (ret)
Signature · 1 line
2.43.0
#4 lore raw

Re: [PATCH 2/6] ASoC: samsung: aries_wm8994: Drop redundant probe error messages

Quoted 4 lines · On 8/11/2026 11:05 AM, [email protected] wrote:

From: bui duc phuc <[email protected]>

Remove the probe error messages to avoid duplicate error reporting, since the error is already reported by the called functions.

...

sound/soc/samsung/aries_wm8994.c static int aries_audio_probe(struct platform_device *pdev) · line 677

Quoted 9 lines
sound/soc/samsung/aries_wm8994.c +1 -3
@@ -671,10 +667,8 @@ static int aries_audio_probe(struct platform_device *pdev)
 
  	ret = devm_snd_soc_register_component(dev, &aries_component,
  				aries_ext_dai, ARRAY_SIZE(aries_ext_dai));
-	if (ret < 0) {
-		dev_err(dev, "Failed to register component: %d\n", ret);
+	if (ret < 0)
  		goto out;
-	}

To be fair, xxx_snd_soc_register_component(), both the devres and the non-devres equivalent do not report anything. The component_initialize() and component_add() do though, most of the time.

Quoted 3 lines
sound/soc/samsung/aries_wm8994.c +0 -0
  	ret = devm_snd_soc_register_card(dev, card);
  	if (ret)
#5 lore raw

Re: [PATCH 2/6] ASoC: samsung: aries_wm8994: Drop redundant probe error messages

Hi Cezary,

Thank you for your review.

Quoted 5 lines

To be fair, xxx_snd_soc_register_component(), both the devres and the non-devres equivalent do not report anything. The component_initialize() and component_add() do though, most of the time.

Yes, you're right. I checked and all the error paths before returning already log an error, except for -ENOMEM, which by convention doesn't need to be logged.

I'll update the commit message to clarify that the error is logged deeper in the call chain rather than by the function called directly. Something like:

-------
The functions called here don't log the error themselves, but the error is already reported deeper in the call chain, so the dev_err() calls are redundant and can be removed.
-------
Does this look accurate to you?

Best regards,
Phuc

#6 lore raw

Re: [PATCH 2/6] ASoC: samsung: aries_wm8994: Drop redundant probe error messages

Quoted 11 lines · Bui Duc Phuc
Quoted 4 lines

To be fair, xxx_snd_soc_register_component(), both the devres and the non-devres equivalent do not report anything. The component_initialize() and component_add() do though, most of the time.

Yes, you're right. I checked and all the error paths before returning already log an error, except for -ENOMEM, which by convention doesn't need to be logged.

I'll update the commit message to clarify that the error is logged deeper in the call chain rather than by the function called directly. Something like:

Quoted 6 lines

-------
The functions called here don't log the error themselves, but the error is already reported deeper in the call chain, so the dev_err() calls are redundant and can be removed.
-------
Does this look accurate to you?

Looks good.

#7 lore raw

PATCH 3/6 ASoC: samsung: pcm: Use dev_err_probe() for error handling

In reply to [email protected]

From: bui duc phuc <[email protected]>

Replace dev_err() with dev_err_probe() to prevent log spam when probe returns -EPROBE_DEFER.

---
 sound/soc/samsung/pcm.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)
sound/soc/samsung/pcm.c +5 -6
index 309f024bf2a4..7e7284125c3e 100644
@@ -499,10 +499,9 @@ static int s3c_pcm_dev_probe(struct platform_device *pdev)
 		return PTR_ERR(pcm->regs);
 
 	pcm->cclk = devm_clk_get(&pdev->dev, "audio-bus");
-	if (IS_ERR(pcm->cclk)) {
-		dev_err(&pdev->dev, "failed to get audio-bus clock\n");
-		return PTR_ERR(pcm->cclk);
-	}
+	if (IS_ERR(pcm->cclk))
+		return dev_err_probe(&pdev->dev, PTR_ERR(pcm->cclk),
+				     "failed to get audio-bus clock\n");
 	ret = clk_prepare_enable(pcm->cclk);
 	if (ret)
 		return ret;
@@ -512,8 +511,8 @@ static int s3c_pcm_dev_probe(struct platform_device *pdev)
 
 	pcm->pclk = devm_clk_get(&pdev->dev, "pcm");
 	if (IS_ERR(pcm->pclk)) {
-		dev_err(&pdev->dev, "failed to get pcm clock\n");
-		ret = PTR_ERR(pcm->pclk);
+		ret = dev_err_probe(&pdev->dev, PTR_ERR(pcm->pclk),
+				    "failed to get pcm clock\n");
 		goto err_dis_cclk;
 	}
 	ret = clk_prepare_enable(pcm->pclk);
Signature · 1 line
2.43.0
#9 lore raw

PATCH 4/6 ASoC: samsung: pcm: Drop redundant probe error messages

In reply to [email protected]

From: bui duc phuc <[email protected]>

Remove the probe error messages to avoid duplicate error reporting, since the error is already reported by the called functions.

---
 sound/soc/samsung/pcm.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
sound/soc/samsung/pcm.c +2 -6
index 7e7284125c3e..8430686760d7 100644
@@ -534,19 +534,15 @@ static int s3c_pcm_dev_probe(struct platform_device *pdev)
 
 	ret = samsung_asoc_dma_platform_register(&pdev->dev, filter,
 						 NULL, NULL, NULL);
-	if (ret) {
-		dev_err(&pdev->dev, "failed to get register DMA: %d\n", ret);
+	if (ret)
 		goto err_dis_pclk;
-	}
 
 	pm_runtime_enable(&pdev->dev);
 
 	ret = devm_snd_soc_register_component(&pdev->dev, &s3c_pcm_component,
 					 &s3c_pcm_dai[pdev->id], 1);
-	if (ret != 0) {
-		dev_err(&pdev->dev, "failed to get register DAI: %d\n", ret);
+	if (ret != 0)
 		goto err_dis_pm;
-	}
 
 	return 0;
 
Signature · 1 line
2.43.0
#10 lore raw

PATCH 5/6 ASoC: samsung: spdif: Drop redundant probe error messages

In reply to [email protected]

From: bui duc phuc <[email protected]>

Remove the probe error messages to avoid duplicate error reporting, since the error is already reported by the called functions.

---
 sound/soc/samsung/spdif.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
sound/soc/samsung/spdif.c +2 -6
index 53eaabaf8956..719083e8e89d 100644
@@ -415,19 +415,15 @@ static int spdif_probe(struct platform_device *pdev)
 
 	ret = samsung_asoc_dma_platform_register(&pdev->dev, filter,
 						 NULL, NULL, NULL);
-	if (ret) {
-		dev_err(&pdev->dev, "failed to register DMA: %d\n", ret);
+	if (ret)
 		goto err2;
-	}
 
 	dev_set_drvdata(&pdev->dev, spdif);
 
 	ret = devm_snd_soc_register_component(&pdev->dev,
 			&samsung_spdif_component, &samsung_spdif_dai, 1);
-	if (ret != 0) {
-		dev_err(&pdev->dev, "fail to register dai\n");
+	if (ret != 0)
 		goto err2;
-	}
 
 	return 0;
 err2:
Signature · 1 line
2.43.0
#11 lore raw

Re: [PATCH 5/6] ASoC: samsung: spdif: Drop redundant probe error messages

Quoted 4 lines · On 8/11/2026 11:05 AM, [email protected] wrote:

From: bui duc phuc <[email protected]>

Remove the probe error messages to avoid duplicate error reporting, since the error is already reported by the called functions.

...

sound/soc/samsung/spdif.c static int spdif_probe(struct platform_device *pdev) · line 419

Quoted 6 lines
sound/soc/samsung/spdif.c +0 -2
@@ -415,19 +415,15 @@ static int spdif_probe(struct platform_device *pdev)
 
  	ret = samsung_asoc_dma_platform_register(&pdev->dev, filter,
  						 NULL, NULL, NULL);
-	if (ret) {
-		dev_err(&pdev->dev, "failed to register DMA: %d\n", ret);

Which function reports the dmaengine registration failure?

Quoted 3 lines
sound/soc/samsung/spdif.c +1 -1
+	if (ret)
  		goto err2;
-	}
#12 lore raw

PATCH 6/6 ASoC: samsung: tm2_wm5110: Drop redundant probe error messages

In reply to [email protected]

From: bui duc phuc <[email protected]>

Remove the probe error messages to avoid duplicate error reporting, since the error is already reported by the called functions.

---
 sound/soc/samsung/tm2_wm5110.c | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)
sound/soc/samsung/tm2_wm5110.c +3 -9
index f1f59e059f5d..f4912826dfd4 100644
@@ -518,19 +518,15 @@ static int tm2_probe(struct platform_device *pdev)
 	}
 
 	ret = snd_soc_of_parse_card_name(card, "model");
-	if (ret < 0) {
-		dev_err(dev, "Card name is not specified\n");
+	if (ret < 0)
 		return ret;
-	}
 
 	ret = snd_soc_of_parse_audio_routing(card, "audio-routing");
 	if (ret < 0) {
 		/* Backwards compatible way */
 		ret = snd_soc_of_parse_audio_routing(card, "samsung,audio-routing");
-		if (ret < 0) {
-			dev_err(dev, "Audio routing is not specified or invalid\n");
+		if (ret < 0)
 			return ret;
-		}
 	}
 
 	card->aux_dev[0].dlc.of_node = of_parse_phandle(dev->of_node,
@@ -609,10 +605,8 @@ static int tm2_probe(struct platform_device *pdev)
 
 	ret = devm_snd_soc_register_component(dev, &tm2_component,
 				tm2_ext_dai, ARRAY_SIZE(tm2_ext_dai));
-	if (ret < 0) {
-		dev_err(dev, "Failed to register component: %d\n", ret);
+	if (ret < 0)
 		goto dai_node_put;
-	}
 
 	ret = devm_snd_soc_register_card(dev, card);
 	if (ret < 0) {
Signature · 1 line
2.43.0