[PATCH v2 07/14] ASoC: mediatek: mt8195: Fix runtime resume error handling
From: phucduc . bui
Date: Mon Oct 05 2026 - 07:06:27 EST
From: bui duc phuc <phucduc.bui@xxxxxxxxx>
Check and propagate errors when enabling the register access and main
clocks during runtime resume.
If regcache_sync() or main clock enable fails, restore regmap cache-only
mode and disable the register access clocks before returning the error.
Fixes: 6746cc858259 ("ASoC: mediatek: mt8195: add platform driver")
Signed-off-by: bui duc phuc <phucduc.bui@xxxxxxxxx>
---
sound/soc/mediatek/mt8195/mt8195-afe-pcm.c | 23 +++++++++++++++++-----
1 file changed, 18 insertions(+), 5 deletions(-)
diff --git a/sound/soc/mediatek/mt8195/mt8195-afe-pcm.c b/sound/soc/mediatek/mt8195/mt8195-afe-pcm.c
index 02736949ae6a..bb357cc674cb 100644
--- a/sound/soc/mediatek/mt8195/mt8195-afe-pcm.c
+++ b/sound/soc/mediatek/mt8195/mt8195-afe-pcm.c
@@ -2958,18 +2958,31 @@ static int mt8195_afe_runtime_resume(struct device *dev)
{
struct mtk_base_afe *afe = dev_get_drvdata(dev);
struct mt8195_afe_private *afe_priv = afe->platform_priv;
+ int ret;
- mt8195_afe_enable_reg_rw_clk(afe);
+ ret = mt8195_afe_enable_reg_rw_clk(afe);
+ if (ret)
+ return ret;
if (!afe->regmap || afe_priv->pm_runtime_bypass_reg_ctl)
- goto skip_regmap;
+ return 0;
regcache_cache_only(afe->regmap, false);
- regcache_sync(afe->regmap);
+ ret = regcache_sync(afe->regmap);
+ if (ret)
+ goto err_restore_cache;
+
+ ret = mt8195_afe_enable_main_clock(afe);
+ if (ret)
+ goto err_restore_cache;
- mt8195_afe_enable_main_clock(afe);
-skip_regmap:
return 0;
+
+err_restore_cache:
+ regcache_cache_only(afe->regmap, true);
+ mt8195_afe_disable_reg_rw_clk(afe);
+
+ return ret;
}
static int init_memif_priv_data(struct mtk_base_afe *afe)
--
2.43.0