summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlivier Moysan <olivier.moysan@foss.st.com>2022-11-09 18:08:49 +0100
committerMark Brown <broonie@kernel.org>2022-11-09 17:56:37 +0000
commit7d945b046be3d2605dbb1806e73095aadd7ae129 (patch)
tree90c54ae3ee82cf064e9f8d22787ab843b7b67e71
parent89cdb224f2abe37ec4ac21ba0d9ddeb5a6a9cf68 (diff)
downloadlinux-stable-7d945b046be3d2605dbb1806e73095aadd7ae129.tar.gz
linux-stable-7d945b046be3d2605dbb1806e73095aadd7ae129.tar.bz2
linux-stable-7d945b046be3d2605dbb1806e73095aadd7ae129.zip
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> Link: https://lore.kernel.org/r/20221109170849.273719-1-olivier.moysan@foss.st.com Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r--sound/soc/stm/stm32_adfsdm.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/sound/soc/stm/stm32_adfsdm.c b/sound/soc/stm/stm32_adfsdm.c
index 643fc8a17018..837c1848d9bf 100644
--- a/sound/soc/stm/stm32_adfsdm.c
+++ b/sound/soc/stm/stm32_adfsdm.c
@@ -304,6 +304,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,
@@ -350,6 +355,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;