* [PATCH 7/9] ASoC: wm8978: stop resume after register restore errors
@ 2026-09-06 3:43 Pengpeng Hou
2026-09-07 10:47 ` Charles Keepax
0 siblings, 1 reply; 2+ messages in thread
From: Pengpeng Hou @ 2026-09-06 3:43 UTC (permalink / raw)
To: Liam Girdwood, Mark Brown
Cc: Pengpeng Hou, Jaroslav Kysela, Takashi Iwai,
Guennadi Liakhovetski, patches, linux-sound, linux-kernel
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@163.com>
---
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)
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH 7/9] ASoC: wm8978: stop resume after register restore errors
2026-09-06 3:43 [PATCH 7/9] ASoC: wm8978: stop resume after register restore errors Pengpeng Hou
@ 2026-09-07 10:47 ` Charles Keepax
0 siblings, 0 replies; 2+ messages in thread
From: Charles Keepax @ 2026-09-07 10:47 UTC (permalink / raw)
To: Pengpeng Hou
Cc: Liam Girdwood, Mark Brown, Jaroslav Kysela, Takashi Iwai,
Guennadi Liakhovetski, patches, linux-sound, linux-kernel
On Sun, Sep 06, 2026 at 11:43:19AM +0800, Pengpeng Hou wrote:
> 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@163.com>
> ---
> 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;
What is the thinking on not pushing the bias_level back to off
here?
Thanks,
Charles
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-09-07 10:47 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-06 3:43 [PATCH 7/9] ASoC: wm8978: stop resume after register restore errors Pengpeng Hou
2026-09-07 10:47 ` Charles Keepax
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®