[PATCH 14/21] ASoC: max98095: Move mclk acquisition to the i2c probe
From: Chancel Liu
Date: Mon Sep 21 2026 - 07:21:12 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(component->dev, ...) in the component
probe therefore leaks a clk reference on every card bind/unbind cycle.
Move the devm_clk_get() to max98095_i2c_probe() so the clk reference is
tied to the physical device lifetime.
Signed-off-by: Chancel Liu <chancel.liu@xxxxxxx>
---
sound/soc/codecs/max98095.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/sound/soc/codecs/max98095.c b/sound/soc/codecs/max98095.c
index a64a5ba00379..c827fd47a5b0 100644
--- a/sound/soc/codecs/max98095.c
+++ b/sound/soc/codecs/max98095.c
@@ -2005,11 +2005,6 @@ static int max98095_probe(struct snd_soc_component *component)
struct i2c_client *client;
int ret = 0;
- max98095->mclk = devm_clk_get(component->dev, "mclk");
- if (IS_ERR(max98095->mclk))
- if (PTR_ERR(max98095->mclk) == -EPROBE_DEFER)
- return -EPROBE_DEFER;
-
/* reset the codec, the DSP core, and disable all interrupts */
max98095_reset(component);
@@ -2153,6 +2148,11 @@ static int max98095_i2c_probe(struct i2c_client *i2c)
return ret;
}
+ max98095->mclk = devm_clk_get(&i2c->dev, "mclk");
+ if (IS_ERR(max98095->mclk))
+ if (PTR_ERR(max98095->mclk) == -EPROBE_DEFER)
+ return -EPROBE_DEFER;
+
max98095->devtype = (uintptr_t)i2c_get_match_data(i2c);
i2c_set_clientdata(i2c, max98095);
max98095->pdata = i2c->dev.platform_data;
--
2.50.1