[PATCH] ASoC: nau8822: keep regcache offline while supplies are off
From: Pengpeng Hou
Date: Sun Aug 30 2026 - 10:18:44 EST
nau8822_suspend() disables all codec supplies and marks the register
cache dirty, but leaves regmap in live I/O mode. Resume then attempts
the cache replay without first leaving a corresponding cache-only state.
Enter cache-only mode after the regulators have been disabled
successfully, leave it after the supplies are restored, and stop the
local resume sequence if cache replay fails. Do not power the codec back
down on a resume error, because deferred component resume remains best
effort and continues after the callback.
regulator_bulk_disable() restores regulators already disabled by the
same bulk operation if a later disable fails. Only publish cache-only
state after the whole power-off operation succeeds, so the regmap state
continues to match the hardware state on either outcome.
Fixes: 1e3cb6c321be ("ASoC: nau8822: new codec driver")
Signed-off-by: Pengpeng Hou <pengpeng@xxxxxxxxxxx>
---
sound/soc/codecs/nau8822.c | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/sound/soc/codecs/nau8822.c b/sound/soc/codecs/nau8822.c
index 830164e991a79..889c3b5f6d04f 100644
--- a/sound/soc/codecs/nau8822.c
+++ b/sound/soc/codecs/nau8822.c
@@ -1059,10 +1059,14 @@ static int nau8822_suspend(struct snd_soc_component *component)
{
struct nau8822 *nau8822 = snd_soc_component_get_drvdata(component);
struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component);
+ int ret;
snd_soc_dapm_force_bias_level(dapm, SND_SOC_BIAS_OFF);
- regulator_bulk_disable(NAU8822_NUM_SUPPLIES, nau8822->supplies);
+ ret = regulator_bulk_disable(NAU8822_NUM_SUPPLIES, nau8822->supplies);
+ if (ret)
+ return ret;
+ regcache_cache_only(nau8822->regmap, true);
regcache_mark_dirty(nau8822->regmap);
return 0;
@@ -1072,7 +1076,9 @@ static int nau8822_resume(struct snd_soc_component *component)
{
struct nau8822 *nau8822 = snd_soc_component_get_drvdata(component);
struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component);
- int ret = regulator_bulk_enable(NAU8822_NUM_SUPPLIES, nau8822->supplies);
+ int ret;
+
+ ret = regulator_bulk_enable(NAU8822_NUM_SUPPLIES, nau8822->supplies);
if (ret) {
dev_err(component->dev,
@@ -1082,7 +1088,10 @@ static int nau8822_resume(struct snd_soc_component *component)
fsleep(100);
- regcache_sync(nau8822->regmap);
+ regcache_cache_only(nau8822->regmap, false);
+ ret = regcache_sync(nau8822->regmap);
+ if (ret)
+ return ret;
snd_soc_dapm_force_bias_level(dapm, SND_SOC_BIAS_STANDBY);
base-commit: 32b4e6b134c62e14291206da331891e99e2fb63d
--
2.50.1