[PATCH 18/20] ASoC: wm8996: Unwind supplies on cache replay failure

From: Pengpeng Hou

Date: Fri Aug 28 2026 - 07:35:49 EST


wm8996_set_bias_level() enables supplies and optional LDO state, makes
the regmap live and ignores regcache_sync() before MICBIAS programming.

Return the cache error after restoring cache-only and dirty state,
deasserting the LDO GPIO, and disabling supplies.

The issue was identified via static analysis and manually reviewed.

Fixes: c93993aca45a ("ASoC: Add WM8915 CODEC driver")

Assisted-by: LLM
Signed-off-by: Pengpeng Hou <pengpeng@xxxxxxxxxxx>
---
sound/soc/codecs/wm8996.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/sound/soc/codecs/wm8996.c b/sound/soc/codecs/wm8996.c
index dface555f928..0676a1710fd5 100644
--- a/sound/soc/codecs/wm8996.c
+++ b/sound/soc/codecs/wm8996.c
@@ -1604,7 +1604,16 @@ static int wm8996_set_bias_level(struct snd_soc_component *component,
}

regcache_cache_only(wm8996->regmap, false);
- regcache_sync(wm8996->regmap);
+ ret = regcache_sync(wm8996->regmap);
+ if (ret) {
+ regcache_cache_only(wm8996->regmap, true);
+ regcache_mark_dirty(wm8996->regmap);
+ if (wm8996->ldo_ena)
+ gpiod_set_value_cansleep(wm8996->ldo_ena, 0);
+ regulator_bulk_disable(ARRAY_SIZE(wm8996->supplies),
+ wm8996->supplies);
+ return ret;
+ }
}

/* Bypass the MICBIASes for lowest power */
--
2.43.0