ASoC: stm32: dfsdm: manage cb buffers cleanup

Ensure that resources allocated by iio_channel_get_all_cb()
are released on driver unbind.

Signed-off-by: Olivier Moysan <olivier.moysan@foss.st.com>
Change-Id: I7479c987ad014fd98173ba0179ec07450ed9a182
Reviewed-on: https://gerrit.st.com/c/mpu/oe/st/linux-stm32/+/265130
Reviewed-by: CITOOLS <MDG-smet-aci-reviews@list.st.com>
Reviewed-by: CIBUILD <MDG-smet-aci-builds@list.st.com>
Reviewed-by: Arnaud POULIQUEN <arnaud.pouliquen@st.com>
This commit is contained in:
Olivier Moysan
2022-09-05 15:40:05 +02:00
committed by Eric Fourmont
parent fe5910a621
commit 08ea0e4648

View File

@ -303,6 +303,11 @@ static int stm32_adfsdm_dummy_cb(const void *data, void *private)
return 0;
}
static void stm32_adfsdm_cleanup(void *data)
{
iio_channel_release_all_cb(data);
}
static struct snd_soc_component_driver stm32_adfsdm_soc_platform = {
.open = stm32_adfsdm_pcm_open,
.close = stm32_adfsdm_pcm_close,
@ -349,6 +354,12 @@ static int stm32_adfsdm_probe(struct platform_device *pdev)
if (IS_ERR(priv->iio_cb))
return PTR_ERR(priv->iio_cb);
ret = devm_add_action_or_reset(&pdev->dev, stm32_adfsdm_cleanup, priv->iio_cb);
if (ret < 0) {
dev_err(&pdev->dev, "Unable to add action\n");
return ret;
}
component = devm_kzalloc(&pdev->dev, sizeof(*component), GFP_KERNEL);
if (!component)
return -ENOMEM;