[PATCH 12/20] ASoC: wm8770: Unwind supplies on cache replay failure

Pengpeng Hou <[email protected]>
Newsgroups gmane.linux.sound,gmane.linux.kernel
Message-ID <[email protected]>
wm8770_set_bias_level() enables supplies and then ignores
regcache_sync() during the OFF-to-STANDBY transition.  It continues with
global power-up after an incomplete restore.

Return the cache error and disable the supplies acquired for the failed
transition.

The issue was identified via static analysis and manually reviewed.

Fixes: c046fd4dd613 ("ASoC: WM8770: Initial driver")

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

diff --git a/sound/soc/codecs/wm8770.c b/sound/soc/codecs/wm8770.c
index b8b4d1e823e6..5bcad0729ece 100644
--- a/sound/soc/codecs/wm8770.c
+++ b/sound/soc/codecs/wm8770.c
@@ -517,7 +517,12 @@ static int wm8770_set_bias_level(struct snd_soc_component *component,
 				return ret;
 			}
 
-			regcache_sync(wm8770->regmap);
+			ret = regcache_sync(wm8770->regmap);
+			if (ret) {
+				regulator_bulk_disable(ARRAY_SIZE(wm8770->supplies),
+						       wm8770->supplies);
+				return ret;
+			}
 
 			/* global powerup */
 			snd_soc_component_write(component, WM8770_PWDNCTRL, 0);
-- 
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.