[PATCH 1/4] ASoC: adau7002: Allocate private data in platform probe

From: Arina Kharlamova via B4 Relay

Date: Tue Dec 01 2026 - 14:12:31 EST


From: Arina Kharlamova <arina.kharlamova@xxxxxxxxxxxx>

adau7002_component_probe() allocates the driver private data with
devm_kzalloc_obj() on the platform device. The component probe runs
every time a sound card binds the component, but the allocation is
released only when the platform device is unbound, so every card bind
leaves one more allocation behind.

Allocate the private data and read the "wakeup-delay-ms" property in
adau7002_probe() instead and drop the component probe callback. The
component is registered on the same device, so
snd_soc_component_get_drvdata() in adau7002_aif_event() still finds it.

Fixes: 7b57085a33ce ("ASoC: ADAU7002: Add optional delay before start of capture")
Signed-off-by: Arina Kharlamova <arina.kharlamova@xxxxxxxxxxxx>
---
sound/soc/codecs/adau7002.c | 28 +++++++++++-----------------
1 file changed, 11 insertions(+), 17 deletions(-)

diff --git a/sound/soc/codecs/adau7002.c b/sound/soc/codecs/adau7002.c
index 97f54bca1539..3bf48a80153f 100644
--- a/sound/soc/codecs/adau7002.c
+++ b/sound/soc/codecs/adau7002.c
@@ -37,22 +37,6 @@ static int adau7002_aif_event(struct snd_soc_dapm_widget *w,
return 0;
}

-static int adau7002_component_probe(struct snd_soc_component *component)
-{
- struct adau7002_priv *adau7002;
-
- adau7002 = devm_kzalloc_obj(component->dev, *adau7002);
- if (!adau7002)
- return -ENOMEM;
-
- device_property_read_u32(component->dev, "wakeup-delay-ms",
- &adau7002->wakeup_delay);
-
- snd_soc_component_set_drvdata(component, adau7002);
-
- return 0;
-}
-
static const struct snd_soc_dapm_widget adau7002_widgets[] = {
SND_SOC_DAPM_AIF_OUT_E("ADAU AIF", "Capture", 0,
SND_SOC_NOPM, 0, 0, adau7002_aif_event,
@@ -82,7 +66,6 @@ static struct snd_soc_dai_driver adau7002_dai = {
};

static const struct snd_soc_component_driver adau7002_component_driver = {
- .probe = adau7002_component_probe,
.dapm_widgets = adau7002_widgets,
.num_dapm_widgets = ARRAY_SIZE(adau7002_widgets),
.dapm_routes = adau7002_routes,
@@ -94,6 +77,17 @@ static const struct snd_soc_component_driver adau7002_component_driver = {

static int adau7002_probe(struct platform_device *pdev)
{
+ struct adau7002_priv *adau7002;
+
+ adau7002 = devm_kzalloc_obj(&pdev->dev, *adau7002);
+ if (!adau7002)
+ return -ENOMEM;
+
+ device_property_read_u32(&pdev->dev, "wakeup-delay-ms",
+ &adau7002->wakeup_delay);
+
+ platform_set_drvdata(pdev, adau7002);
+
return devm_snd_soc_register_component(&pdev->dev,
&adau7002_component_driver,
&adau7002_dai, 1);

--
Git-157)