[PATCH 05/15] ASoC: mediatek: mt8192: switch to devm_clk_get_optional()
From: phucduc . bui
Date: Fri Sep 18 2026 - 09:50:12 EST
From: bui duc phuc <phucduc.bui@xxxxxxxxx>
Switch from devm_clk_get() to devm_clk_get_optional() when requesting
clocks, as optional clocks automatically return NULL when not present
instead of requiring manual check and NULL assignment.
Additionally, handle clock errors properly using dev_err_probe() to
propagate error codes (such as -EPROBE_DEFER) on failure instead of
just printing a warning and continuing with NULL pointers.
Fixes: 125ab5d588b0 ("ASoC: mediatek: mt8192: add platform driver")
Signed-off-by: bui duc phuc <phucduc.bui@xxxxxxxxx>
---
sound/soc/mediatek/mt8192/mt8192-afe-clk.c | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
diff --git a/sound/soc/mediatek/mt8192/mt8192-afe-clk.c b/sound/soc/mediatek/mt8192/mt8192-afe-clk.c
index 77f596cab92d..9b9a3465ddb5 100644
--- a/sound/soc/mediatek/mt8192/mt8192-afe-clk.c
+++ b/sound/soc/mediatek/mt8192/mt8192-afe-clk.c
@@ -672,13 +672,10 @@ int mt8192_init_clock(struct mtk_base_afe *afe)
return -ENOMEM;
for (i = 0; i < CLK_NUM; i++) {
- afe_priv->clk[i] = devm_clk_get(afe->dev, aud_clks[i]);
- if (IS_ERR(afe_priv->clk[i])) {
- dev_warn(afe->dev, "%s devm_clk_get %s fail, ret %ld\n",
- __func__,
- aud_clks[i], PTR_ERR(afe_priv->clk[i]));
- afe_priv->clk[i] = NULL;
- }
+ afe_priv->clk[i] = devm_clk_get_optional(afe->dev, aud_clks[i]);
+ if (IS_ERR(afe_priv->clk[i]))
+ return dev_err_probe(afe->dev, PTR_ERR(afe_priv->clk[i]),
+ "failed to get clock %s\n", aud_clks[i]);
}
afe_priv->apmixedsys = syscon_regmap_lookup_by_phandle(of_node,
--
2.43.0