ASoC: wm8978: stop resume after register restore errors
Subsystems (3)
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.
--- sound/soc/codecs/wm8978.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-)
sound/soc/codecs/wm8978.c +14 -4
@@ -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)
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 5Signed-off-by Pengpeng Hou <[email protected]>--- sound/soc/codecs/wm8978.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-)sound/soc/codecs/wm8978.c +7
-2@@ -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