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

From: Pengpeng Hou

Date: Sat Sep 05 2026 - 23:49:59 EST


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
Signed-off-by: Pengpeng Hou <hppiscas@xxxxxxx>
---
sound/soc/codecs/wm8978.c | 18 ++++++++++++++----
1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/sound/soc/codecs/wm8978.c b/sound/soc/codecs/wm8978.c
index ad8064bbaaac..241d17d81ecb 100644
--- a/sound/soc/codecs/wm8978.c
+++ b/sound/soc/codecs/wm8978.c
@@ -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;
}
--
2.50.1 (Apple Git-155)