[PATCH 03/10] ASoC: mediatek: mt8196: fix MCK error handling

From: phucduc . bui

Date: Tue Sep 29 2026 - 02:13:06 EST


From: bui duc phuc <phucduc.bui@xxxxxxxxx>

Disable the clock if setting its rate fails after the clock has been
enabled, preventing it from being left enabled on the error path.

Fixes: 7384ecab34eb ("ASoC: mediatek: mt8196: support audio clock control")
Signed-off-by: bui duc phuc <phucduc.bui@xxxxxxxxx>
---
sound/soc/mediatek/mt8196/mt8196-afe-clk.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/sound/soc/mediatek/mt8196/mt8196-afe-clk.c b/sound/soc/mediatek/mt8196/mt8196-afe-clk.c
index 1dc4210e58c7..1d107b85d03c 100644
--- a/sound/soc/mediatek/mt8196/mt8196-afe-clk.c
+++ b/sound/soc/mediatek/mt8196/mt8196-afe-clk.c
@@ -502,8 +502,10 @@ int mt8196_mck_enable(struct mtk_base_afe *afe, int mck_id, int rate)
return ret;

ret = mt8196_afe_set_clk_rate(afe, afe_priv->clk[div_clk_id], rate);
- if (ret)
+ if (ret) {
+ mt8196_afe_disable_clk(afe, afe_priv->clk[div_clk_id]);
return ret;
+ }

return 0;
}
--
2.43.0