Skip to contentSkip to conversation

ASoC: wm8978: stop resume after register restore errors

PATCH In review Pengpeng Hou 2 participants 2 messages Sep 6 – Sep 7

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 7/9 ASoC: wm8978: stop resume after register restore errors

wm8978_resume() ignores failures from cache replay, bias restoration and PLL re-enable. It can therefore continue publishing later resume steps after the codec restore transaction has already failed.

Return the first negative result from those ordered operations. Treat the positive "register changed" result from snd_soc_component_update_bits() as success, as required by the component resume callback contract. The ASoC wrapper reports failures and retains best-effort card resume.

The issue was found by our static-analysis tool and manually reviewed.

Fixes 0d34e91596ef ("ASoC: add a WM8978 codec driver")
Assisted-by gpt 5
---
 sound/soc/codecs/wm8978.c | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)
sound/soc/codecs/wm8978.c +14 -4
index ad8064bbaaac..241d17d81ecb 100644
@@ -940,15 +940,25 @@ static int wm8978_resume(struct snd_soc_component *component)
 {
 	struct wm8978_priv *wm8978 = snd_soc_component_get_drvdata(component);
 	struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component);
+	int ret;
 
 	/* Sync reg_cache with the hardware */
-	regcache_sync(wm8978->regmap);
+	ret = regcache_sync(wm8978->regmap);
+	if (ret)
+		return ret;
 
-	snd_soc_dapm_force_bias_level(dapm, SND_SOC_BIAS_STANDBY);
+	ret = snd_soc_dapm_force_bias_level(dapm, SND_SOC_BIAS_STANDBY);
+	if (ret)
+		return ret;
 
-	if (wm8978->f_pllout)
+	if (wm8978->f_pllout) {
 		/* Switch PLL on */
-		snd_soc_component_update_bits(component, WM8978_POWER_MANAGEMENT_1, 0x20, 0x20);
+		ret = snd_soc_component_update_bits(component,
+						    WM8978_POWER_MANAGEMENT_1,
+						    0x20, 0x20);
+		if (ret < 0)
+			return ret;
+	}
 
 	return 0;
 }
Signature · 1 line
2.50.1 (Apple Git-155)
#1 lore raw
Quoted 39 lines · Pengpeng Hou

wm8978_resume() ignores failures from cache replay, bias restoration and PLL re-enable. It can therefore continue publishing later resume steps after the codec restore transaction has already failed.

Return the first negative result from those ordered operations. Treat the positive "register changed" result from snd_soc_component_update_bits() as success, as required by the component resume callback contract. The ASoC wrapper reports failures and retains best-effort card resume.

The issue was found by our static-analysis tool and manually reviewed.

Fixes 0d34e91596ef ("ASoC: add a WM8978 codec driver")
Assisted-by gpt 5
---
 sound/soc/codecs/wm8978.c | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)
sound/soc/codecs/wm8978.c +7 -2
index ad8064bbaaac..241d17d81ecb 100644
@@ -940,15 +940,25 @@ static int wm8978_resume(struct snd_soc_component *component)
 {
 	struct wm8978_priv *wm8978 = snd_soc_component_get_drvdata(component);
 	struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component);
+	int ret;
 
 	/* Sync reg_cache with the hardware */
-	regcache_sync(wm8978->regmap);
+	ret = regcache_sync(wm8978->regmap);
+	if (ret)
+		return ret;
 
-	snd_soc_dapm_force_bias_level(dapm, SND_SOC_BIAS_STANDBY);
+	ret = snd_soc_dapm_force_bias_level(dapm, SND_SOC_BIAS_STANDBY);
+	if (ret)
+		return ret;

sound/soc/codecs/wm8978.c static int wm8978_resume(struct snd_soc_component *component) · line 960

Quoted 10 lines
sound/soc/codecs/wm8978.c +6 -2
 
-	if (wm8978->f_pllout)
+	if (wm8978->f_pllout) {
 		/* Switch PLL on */
-		snd_soc_component_update_bits(component, WM8978_POWER_MANAGEMENT_1, 0x20, 0x20);
+		ret = snd_soc_component_update_bits(component,
+						    WM8978_POWER_MANAGEMENT_1,
+						    0x20, 0x20);
+		if (ret < 0)
+			return ret;

What is the thinking on not pushing the bias_level back to off here?

Thanks,
Charles