[PATCH 11/21] ASoC: rt5514: Move clk acquisition to the i2c probe

From: Chancel Liu

Date: Mon Sep 21 2026 - 07:39:50 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 clocks with devm_clk_get*(component->dev, ...) in the
component probe therefore leaks clk references on every card
bind/unbind cycle.

Move the mclk and dsp_calib_clk acquisition to rt5514_i2c_probe() so
the clk references are tied to the physical device lifetime.

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

diff --git a/sound/soc/codecs/rt5514.c b/sound/soc/codecs/rt5514.c
index 753143e2d11f..a33fbc9fb047 100644
--- a/sound/soc/codecs/rt5514.c
+++ b/sound/soc/codecs/rt5514.c
@@ -1099,18 +1099,6 @@ static int rt5514_set_bias_level(struct snd_soc_component *component,
static int rt5514_probe(struct snd_soc_component *component)
{
struct rt5514_priv *rt5514 = snd_soc_component_get_drvdata(component);
- struct platform_device *pdev = to_platform_device(component->dev);
-
- rt5514->mclk = devm_clk_get_optional(component->dev, "mclk");
- if (IS_ERR(rt5514->mclk))
- return PTR_ERR(rt5514->mclk);
-
- if (rt5514->pdata.dsp_calib_clk_name) {
- rt5514->dsp_calib_clk = devm_clk_get(&pdev->dev,
- rt5514->pdata.dsp_calib_clk_name);
- if (PTR_ERR(rt5514->dsp_calib_clk) == -EPROBE_DEFER)
- return -EPROBE_DEFER;
- }

rt5514->component = component;
rt5514->pll3_cal_value = 0x0078b000;
@@ -1285,6 +1273,17 @@ static int rt5514_i2c_probe(struct i2c_client *i2c)
else
rt5514_parse_dp(rt5514, &i2c->dev);

+ rt5514->mclk = devm_clk_get_optional(&i2c->dev, "mclk");
+ if (IS_ERR(rt5514->mclk))
+ return PTR_ERR(rt5514->mclk);
+
+ if (rt5514->pdata.dsp_calib_clk_name) {
+ rt5514->dsp_calib_clk = devm_clk_get(&i2c->dev,
+ rt5514->pdata.dsp_calib_clk_name);
+ if (PTR_ERR(rt5514->dsp_calib_clk) == -EPROBE_DEFER)
+ return -EPROBE_DEFER;
+ }
+
rt5514->i2c_regmap = devm_regmap_init_i2c(i2c, &rt5514_i2c_regmap);
if (IS_ERR(rt5514->i2c_regmap)) {
ret = PTR_ERR(rt5514->i2c_regmap);
--
2.50.1