[PATCH 10/21] ASoC: rt5616: Move mclk acquisition to the i2c probe

From: Chancel Liu

Date: Mon Sep 21 2026 - 07:33:43 EST


From: Chancel Liu <chancel.liu@xxxxxxx>

component->dev is the underlying i2c device whose devres is only
released on physical device removal, not on ASoC card unbind. Getting
the codec clock with devm_clk_get_optional(component->dev, ...) in the
component probe therefore leaks a clk reference on every card
bind/unbind cycle.

Move the devm_clk_get_optional() to rt5616_i2c_probe() so the clk
reference is tied to the physical device lifetime.

Signed-off-by: Chancel Liu <chancel.liu@xxxxxxx>
---
sound/soc/codecs/rt5616.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/sound/soc/codecs/rt5616.c b/sound/soc/codecs/rt5616.c
index 3f9d97d04d48..e30e3b563c90 100644
--- a/sound/soc/codecs/rt5616.c
+++ b/sound/soc/codecs/rt5616.c
@@ -1222,11 +1222,6 @@ static int rt5616_probe(struct snd_soc_component *component)
{
struct rt5616_priv *rt5616 = snd_soc_component_get_drvdata(component);

- /* Check if MCLK provided */
- rt5616->mclk = devm_clk_get_optional(component->dev, "mclk");
- if (IS_ERR(rt5616->mclk))
- return PTR_ERR(rt5616->mclk);
-
rt5616->component = component;

return 0;
@@ -1357,6 +1352,11 @@ static int rt5616_i2c_probe(struct i2c_client *i2c)

i2c_set_clientdata(i2c, rt5616);

+ /* Check if MCLK provided */
+ rt5616->mclk = devm_clk_get_optional(&i2c->dev, "mclk");
+ if (IS_ERR(rt5616->mclk))
+ return PTR_ERR(rt5616->mclk);
+
rt5616->regmap = devm_regmap_init_i2c(i2c, &rt5616_regmap);
if (IS_ERR(rt5616->regmap)) {
ret = PTR_ERR(rt5616->regmap);
--
2.50.1