[PATCH 08/21] ASoC: es8328: Move clk acquisition to the bus probe
From: Chancel Liu
Date: Mon Sep 21 2026 - 07:15:58 EST
From: Chancel Liu <chancel.liu@xxxxxxx>
component->dev is the underlying i2c/spi 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 es8328_probe() (the shared i2c/spi bus level
probe) so the clk reference is tied to the physical device lifetime.
Signed-off-by: Chancel Liu <chancel.liu@xxxxxxx>
---
sound/soc/codecs/es8328.c | 13 +++++--------
1 file changed, 5 insertions(+), 8 deletions(-)
diff --git a/sound/soc/codecs/es8328.c b/sound/soc/codecs/es8328.c
index 7d52b5d9d061..37fda2f42b0c 100644
--- a/sound/soc/codecs/es8328.c
+++ b/sound/soc/codecs/es8328.c
@@ -829,14 +829,6 @@ static int es8328_component_probe(struct snd_soc_component *component)
return ret;
}
- /* Setup clocks */
- es8328->clk = devm_clk_get(component->dev, NULL);
- if (IS_ERR(es8328->clk)) {
- dev_err(component->dev, "codec clock missing or invalid\n");
- ret = PTR_ERR(es8328->clk);
- goto clk_fail;
- }
-
ret = clk_prepare_enable(es8328->clk);
if (ret) {
dev_err(component->dev, "unable to prepare codec clk\n");
@@ -906,6 +898,11 @@ int es8328_probe(struct device *dev, struct regmap *regmap)
es8328->regmap = regmap;
+ es8328->clk = devm_clk_get(dev, NULL);
+ if (IS_ERR(es8328->clk))
+ return dev_err_probe(dev, PTR_ERR(es8328->clk),
+ "codec clock missing or invalid\n");
+
for (i = 0; i < ARRAY_SIZE(es8328->supplies); i++)
es8328->supplies[i].supply = supply_names[i];
--
2.50.1