[PATCH v3 04/12] ASoC: mediatek: mt8189: Propagate reg_rw clock errors

From: phucduc . bui

Date: Wed Sep 16 2026 - 01:02:20 EST


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

mt8189_afe_enable_reg_rw_clk() currently ignores errors from clock
enable and parent operations.

Propagate these errors and clean up the clocks before returning the
error.

Fixes: dc637ffeed6c ("ASoC: mediatek: mt8189: support audio clock control")
Signed-off-by: bui duc phuc <phucduc.bui@xxxxxxxxx>
---

Changes in v2:
- Update the names of the goto labels.

sound/soc/mediatek/mt8189/mt8189-afe-clk.c | 31 +++++++++++++++++-----
1 file changed, 25 insertions(+), 6 deletions(-)

diff --git a/sound/soc/mediatek/mt8189/mt8189-afe-clk.c b/sound/soc/mediatek/mt8189/mt8189-afe-clk.c
index 7fe9d01006d5..1132c924158d 100644
--- a/sound/soc/mediatek/mt8189/mt8189-afe-clk.c
+++ b/sound/soc/mediatek/mt8189/mt8189-afe-clk.c
@@ -700,17 +700,36 @@ int mt8189_mck_disable(struct mtk_base_afe *afe, int mck_id)
int mt8189_afe_enable_reg_rw_clk(struct mtk_base_afe *afe)
{
struct mt8189_afe_private *afe_priv = afe->platform_priv;
+ int ret;

/* bus clock for AFE internal access, like AFE SRAM */
- mt8189_afe_enable_clk(afe, afe_priv->clk[MT8189_CLK_TOP_MUX_AUDIOINTBUS]);
- mt8189_afe_set_clk_parent(afe, afe_priv->clk[MT8189_CLK_TOP_MUX_AUDIOINTBUS],
- afe_priv->clk[MT8189_CLK_TOP_CLK26M]);
+ ret = mt8189_afe_enable_clk(afe, afe_priv->clk[MT8189_CLK_TOP_MUX_AUDIOINTBUS]);
+ if (ret)
+ return ret;
+
+ ret = mt8189_afe_set_clk_parent(afe, afe_priv->clk[MT8189_CLK_TOP_MUX_AUDIOINTBUS],
+ afe_priv->clk[MT8189_CLK_TOP_CLK26M]);
+ if (ret)
+ goto err_disable_audiointbus_clk;
+
/* enable audio clock source */
- mt8189_afe_enable_clk(afe, afe_priv->clk[MT8189_CLK_TOP_MUX_AUDIO_H]);
- mt8189_afe_set_clk_parent(afe, afe_priv->clk[MT8189_CLK_TOP_MUX_AUDIO_H],
- afe_priv->clk[MT8189_CLK_TOP_CLK26M]);
+ ret = mt8189_afe_enable_clk(afe, afe_priv->clk[MT8189_CLK_TOP_MUX_AUDIO_H]);
+ if (ret)
+ goto err_disable_audiointbus_clk;
+
+ ret = mt8189_afe_set_clk_parent(afe, afe_priv->clk[MT8189_CLK_TOP_MUX_AUDIO_H],
+ afe_priv->clk[MT8189_CLK_TOP_CLK26M]);
+ if (ret)
+ goto err_disable_audio_h_clk;

return 0;
+
+err_disable_audio_h_clk:
+ mt8189_afe_disable_clk(afe, afe_priv->clk[MT8189_CLK_TOP_MUX_AUDIO_H]);
+err_disable_audiointbus_clk:
+ mt8189_afe_disable_clk(afe, afe_priv->clk[MT8189_CLK_TOP_MUX_AUDIOINTBUS]);
+
+ return ret;
}

int mt8189_afe_disable_reg_rw_clk(struct mtk_base_afe *afe)
--
2.43.0