[PATCH 16/20] ASoC: wm8991: Propagate cache replay errors from bias restore

Pengpeng Hou <[email protected]>
Newsgroups gmane.linux.sound,gmane.linux.kernel
Message-ID <[email protected]>
wm8991_set_bias_level() ignores regcache_sync() and proceeds with a long
anti-pop sequence during OFF-to-STANDBY.

Return the cache error before that sequence and keep the cache dirty for
a retry.

The issue was identified via static analysis and manually reviewed.

Fixes: 203db220718c ("ASoC: WM8991: Add initial WM8991 driver")

Assisted-by: LLM
Signed-off-by: Pengpeng Hou <[email protected]>
---
 sound/soc/codecs/wm8991.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/sound/soc/codecs/wm8991.c b/sound/soc/codecs/wm8991.c
index 225c235d3d89..ce66bd3ba7af 100644
--- a/sound/soc/codecs/wm8991.c
+++ b/sound/soc/codecs/wm8991.c
@@ -1083,6 +1083,7 @@ static int wm8991_set_bias_level(struct snd_soc_component *component,
 	struct wm8991_priv *wm8991 = snd_soc_component_get_drvdata(component);
 	struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component);
 	u16 val;
+	int ret;
 
 	switch (level) {
 	case SND_SOC_BIAS_ON:
@@ -1097,7 +1098,11 @@ static int wm8991_set_bias_level(struct snd_soc_component *component,
 
 	case SND_SOC_BIAS_STANDBY:
 		if (snd_soc_dapm_get_bias_level(dapm) == SND_SOC_BIAS_OFF) {
-			regcache_sync(wm8991->regmap);
+			ret = regcache_sync(wm8991->regmap);
+			if (ret) {
+				regcache_mark_dirty(wm8991->regmap);
+				return ret;
+			}
 			/* Enable all output discharge bits */
 			snd_soc_component_write(component, WM8991_ANTIPOP1, WM8991_DIS_LLINE |
 				      WM8991_DIS_RLINE | WM8991_DIS_OUT3 |
-- 
2.43.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.