Skip to content

Commit 7d945b0

Browse files
Olivier Moysanbroonie
authored andcommitted
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 <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 89cdb22 commit 7d945b0

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

sound/soc/stm/stm32_adfsdm.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,11 @@ static int stm32_adfsdm_dummy_cb(const void *data, void *private)
304304
return 0;
305305
}
306306

307+
static void stm32_adfsdm_cleanup(void *data)
308+
{
309+
iio_channel_release_all_cb(data);
310+
}
311+
307312
static struct snd_soc_component_driver stm32_adfsdm_soc_platform = {
308313
.open = stm32_adfsdm_pcm_open,
309314
.close = stm32_adfsdm_pcm_close,
@@ -350,6 +355,12 @@ static int stm32_adfsdm_probe(struct platform_device *pdev)
350355
if (IS_ERR(priv->iio_cb))
351356
return PTR_ERR(priv->iio_cb);
352357

358+
ret = devm_add_action_or_reset(&pdev->dev, stm32_adfsdm_cleanup, priv->iio_cb);
359+
if (ret < 0) {
360+
dev_err(&pdev->dev, "Unable to add action\n");
361+
return ret;
362+
}
363+
353364
component = devm_kzalloc(&pdev->dev, sizeof(*component), GFP_KERNEL);
354365
if (!component)
355366
return -ENOMEM;

0 commit comments

Comments
 (0)