summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChancel Liu <chancel.liu@nxp.com>2026-09-23 15:12:59 +0900
committerMark Brown <broonie@kernel.org>2026-09-23 14:22:58 +0200
commitfe15e876d9ee7a205aeafa3dbadd358954ffc901 (patch)
tree35b947d0171fe7a70bb05d05277a2e6f893e4416
parent8635b9033d039bdad19e65faf0450d738d34527f (diff)
ASoC: codecs: wm8985: Move regulator acquisition to the bus probe
component->dev is the underlying i2c/spi device whose devres is only released on physical device removal, not on ASoC card unbind. Getting the regulator supplies with devm_regulator_bulk_get(component->dev, ...) in the component probe therefore leaks the regulator references on every card bind/unbind cycle. Move the devm_regulator_bulk_get() into a helper called from the i2c and spi probes so the supplies are tied to the physical device lifetime. Signed-off-by: Chancel Liu <chancel.liu@nxp.com> Reviewed-by: Charles Keepax <ckeepax@opensource.cirrus.com> Link: https://patch.msgid.link/20260923061305.4041197-16-chancel.liu@oss.nxp.com Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r--sound/soc/codecs/wm8985.c35
1 files changed, 25 insertions, 10 deletions
diff --git a/sound/soc/codecs/wm8985.c b/sound/soc/codecs/wm8985.c
index 77ca9a0feb8a..b5ca4af715c0 100644
--- a/sound/soc/codecs/wm8985.c
+++ b/sound/soc/codecs/wm8985.c
@@ -1024,23 +1024,30 @@ static int wm8985_set_bias_level(struct snd_soc_component *component,
return 0;
}
-static int wm8985_probe(struct snd_soc_component *component)
+static int wm8985_get_regulators(struct device *dev,
+ struct wm8985_priv *wm8985)
{
size_t i;
- struct wm8985_priv *wm8985;
int ret;
- wm8985 = snd_soc_component_get_drvdata(component);
-
for (i = 0; i < ARRAY_SIZE(wm8985->supplies); i++)
wm8985->supplies[i].supply = wm8985_supply_names[i];
- ret = devm_regulator_bulk_get(component->dev, ARRAY_SIZE(wm8985->supplies),
- wm8985->supplies);
- if (ret) {
- dev_err(component->dev, "Failed to request supplies: %d\n", ret);
- return ret;
- }
+ ret = devm_regulator_bulk_get(dev, ARRAY_SIZE(wm8985->supplies),
+ wm8985->supplies);
+ if (ret)
+ dev_err(dev, "Failed to request supplies: %d\n", ret);
+
+ return ret;
+}
+
+static int wm8985_probe(struct snd_soc_component *component)
+{
+ size_t i;
+ struct wm8985_priv *wm8985;
+ int ret;
+
+ wm8985 = snd_soc_component_get_drvdata(component);
ret = regulator_bulk_enable(ARRAY_SIZE(wm8985->supplies),
wm8985->supplies);
@@ -1171,6 +1178,10 @@ static int wm8985_spi_probe(struct spi_device *spi)
return ret;
}
+ ret = wm8985_get_regulators(&spi->dev, wm8985);
+ if (ret)
+ return ret;
+
ret = devm_snd_soc_register_component(&spi->dev,
&soc_component_dev_wm8985, &wm8985_dai, 1);
return ret;
@@ -1207,6 +1218,10 @@ static int wm8985_i2c_probe(struct i2c_client *i2c)
return ret;
}
+ ret = wm8985_get_regulators(&i2c->dev, wm8985);
+ if (ret)
+ return ret;
+
ret = devm_snd_soc_register_component(&i2c->dev,
&soc_component_dev_wm8985, &wm8985_dai, 1);
return ret;