Re: [PATCH 14/19] ASoC: codecs: wm8962: Propagate regcache_sync() errors

From: Richard Fitzgerald

Date: Mon Jul 06 2026 - 07:27:59 EST


On 04/07/2026 5:02 am, Pengpeng Hou wrote:
regcache_sync() can fail while replaying cached register state during
runtime resume. wm8962_runtime_resume() currently ignores that failure
and continues programming the device.

Propagate the error, restore cache-only/dirty state, and unwind the
supplies and clock acquired by runtime resume.

Signed-off-by: Pengpeng Hou <pengpeng@xxxxxxxxxxx>
---
sound/soc/codecs/wm8962.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/sound/soc/codecs/wm8962.c b/sound/soc/codecs/wm8962.c
index de18b1f85a32..2db822fc1de7 100644
--- a/sound/soc/codecs/wm8962.c
+++ b/sound/soc/codecs/wm8962.c
@@ -3937,7 +3937,9 @@ static int wm8962_runtime_resume(struct device *dev)
WM8962_OSC_ENA | WM8962_PLL2_ENA | WM8962_PLL3_ENA,
0);


What about the regmap writes that happen before this?
There is a regmap_write_bits() and two regmap_update_bits() that could
fail before we get to the regcache_sync() but they aren't checked for
error.

- regcache_sync(wm8962->regmap);
+ ret = regcache_sync(wm8962->regmap);
+ if (ret)
+ goto cache_sync_err;
regmap_update_bits(wm8962->regmap, WM8962_ANTI_POP,
WM8962_STARTUP_BIAS_ENA | WM8962_VMID_BUF_ENA,
@@ -3955,6 +3957,11 @@ static int wm8962_runtime_resume(struct device *dev)
return 0;
+cache_sync_err:

Should this error path revert the three regmap writes that were done
before the regcache_sync() ?

+ regcache_cache_only(wm8962->regmap, true);
+ regcache_mark_dirty(wm8962->regmap);
+ regulator_bulk_disable(ARRAY_SIZE(wm8962->supplies),
+ wm8962->supplies);
disable_clock:
clk_disable_unprepare(wm8962->pdata.mclk);
return ret;