summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Brown <broonie@kernel.org>2026-09-14 19:52:47 +0100
committerMark Brown <broonie@kernel.org>2026-09-14 19:52:47 +0100
commitf1c78e3edcfeeee1bcc2c69250bdba53b1f0fe55 (patch)
tree64aee631beb6c36ab26ee1513924ab70ade9abbe
parent4b49d276dba291d34e5e4c40a00e3a280353b652 (diff)
parente88fd9fe81d729992e270c055bf108a48ec52dea (diff)
downloadlinux-next-f1c78e3edcfeeee1bcc2c69250bdba53b1f0fe55.tar.gz
linux-next-f1c78e3edcfeeee1bcc2c69250bdba53b1f0fe55.zip
ASoC: Use devm_of_reserved_mem_device_init()
Mukesh Ojha <mukesh.ojha@oss.qualcomm.com> says: Several ASoC drivers manually manage reserved memory lifetime by calling of_reserved_mem_device_init() in probe and of_reserved_mem_device_release() in remove. This pattern is fragile: any error path between the two that skips the release leaks the reserved memory region for the lifetime of the driver. devm_of_reserved_mem_device_init() was recently introduced to tie the release to the device's devres lifetime automatically. Convert the affected ASoC drivers to use it, removing the manual release calls and any wrapper devres actions. Link: https://patch.msgid.link/20260902194712.2003414-1-mukesh.ojha@oss.qualcomm.com
-rw-r--r--sound/soc/mediatek/mt8173/mt8173-afe-pcm.c2
-rw-r--r--sound/soc/mediatek/mt8183/mt8183-afe-pcm.c13
-rw-r--r--sound/soc/mediatek/mt8186/mt8186-afe-pcm.c2
-rw-r--r--sound/soc/mediatek/mt8188/mt8188-afe-pcm.c2
-rw-r--r--sound/soc/mediatek/mt8189/mt8189-afe-pcm.c16
-rw-r--r--sound/soc/mediatek/mt8192/mt8192-afe-pcm.c11
-rw-r--r--sound/soc/mediatek/mt8195/mt8195-afe-pcm.c2
-rw-r--r--sound/soc/mediatek/mt8196/mt8196-afe-pcm.c14
-rw-r--r--sound/soc/sof/mediatek/mt8186/mt8186.c2
-rw-r--r--sound/soc/sof/mediatek/mt8195/mt8195.c2
-rw-r--r--sound/soc/sprd/sprd-pcm-dma.c3
11 files changed, 13 insertions, 56 deletions
diff --git a/sound/soc/mediatek/mt8173/mt8173-afe-pcm.c b/sound/soc/mediatek/mt8173/mt8173-afe-pcm.c
index c2421f17375b..c95699f84191 100644
--- a/sound/soc/mediatek/mt8173/mt8173-afe-pcm.c
+++ b/sound/soc/mediatek/mt8173/mt8173-afe-pcm.c
@@ -1070,7 +1070,7 @@ static int mt8173_afe_pcm_dev_probe(struct platform_device *pdev)
afe->dev = dev;
- ret = of_reserved_mem_device_init(dev);
+ ret = devm_of_reserved_mem_device_init(dev);
if (ret) {
dev_info(dev, "no reserved memory found, pre-allocating buffers instead\n");
afe->preallocate_buffers = true;
diff --git a/sound/soc/mediatek/mt8183/mt8183-afe-pcm.c b/sound/soc/mediatek/mt8183/mt8183-afe-pcm.c
index 2634699534db..6ad396e3b10d 100644
--- a/sound/soc/mediatek/mt8183/mt8183-afe-pcm.c
+++ b/sound/soc/mediatek/mt8183/mt8183-afe-pcm.c
@@ -766,11 +766,6 @@ static const dai_register_cb dai_register_cbs[] = {
mt8183_dai_memif_register,
};
-static void mt8183_afe_release_reserved_mem(void *data)
-{
- of_reserved_mem_device_release(data);
-}
-
static int mt8183_afe_pcm_dev_probe(struct platform_device *pdev)
{
struct mtk_base_afe *afe;
@@ -795,16 +790,10 @@ static int mt8183_afe_pcm_dev_probe(struct platform_device *pdev)
afe_priv = afe->platform_priv;
afe->dev = dev;
- ret = of_reserved_mem_device_init(dev);
+ ret = devm_of_reserved_mem_device_init(dev);
if (ret) {
dev_info(dev, "no reserved memory found, pre-allocating buffers instead\n");
afe->preallocate_buffers = true;
- } else {
- ret = devm_add_action_or_reset(dev,
- mt8183_afe_release_reserved_mem,
- dev);
- if (ret)
- return ret;
}
/* initial audio related clock */
diff --git a/sound/soc/mediatek/mt8186/mt8186-afe-pcm.c b/sound/soc/mediatek/mt8186/mt8186-afe-pcm.c
index 4bf098657fb4..2f50f78a6f8c 100644
--- a/sound/soc/mediatek/mt8186/mt8186-afe-pcm.c
+++ b/sound/soc/mediatek/mt8186/mt8186-afe-pcm.c
@@ -2840,7 +2840,7 @@ static int mt8186_afe_pcm_dev_probe(struct platform_device *pdev)
afe_priv = afe->platform_priv;
afe->dev = &pdev->dev;
- ret = of_reserved_mem_device_init(dev);
+ ret = devm_of_reserved_mem_device_init(dev);
if (ret) {
dev_info(dev, "no reserved memory found, pre-allocating buffers instead\n");
afe->preallocate_buffers = true;
diff --git a/sound/soc/mediatek/mt8188/mt8188-afe-pcm.c b/sound/soc/mediatek/mt8188/mt8188-afe-pcm.c
index 7b1f5d05f4d6..ab4ce5e86b9d 100644
--- a/sound/soc/mediatek/mt8188/mt8188-afe-pcm.c
+++ b/sound/soc/mediatek/mt8188/mt8188-afe-pcm.c
@@ -3199,7 +3199,7 @@ static int mt8188_afe_pcm_dev_probe(struct platform_device *pdev)
struct regmap *infra_ao;
int i, irq_id, ret;
- ret = of_reserved_mem_device_init(dev);
+ ret = devm_of_reserved_mem_device_init(dev);
if (ret)
dev_dbg(dev, "failed to assign memory region: %d\n", ret);
diff --git a/sound/soc/mediatek/mt8189/mt8189-afe-pcm.c b/sound/soc/mediatek/mt8189/mt8189-afe-pcm.c
index 77cf2b604f6c..04baf7d9132a 100644
--- a/sound/soc/mediatek/mt8189/mt8189-afe-pcm.c
+++ b/sound/soc/mediatek/mt8189/mt8189-afe-pcm.c
@@ -2421,11 +2421,6 @@ static const struct reg_sequence mt8189_cg_patch[] = {
{ AUDIO_TOP_CON4, 0x361c },
};
-static void mt8189_afe_release_reserved_mem(void *data)
-{
- of_reserved_mem_device_release(data);
-}
-
static int mt8189_afe_pcm_dev_probe(struct platform_device *pdev)
{
int ret, i;
@@ -2439,16 +2434,9 @@ static int mt8189_afe_pcm_dev_probe(struct platform_device *pdev)
if (ret)
return ret;
- ret = of_reserved_mem_device_init(dev);
- if (ret) {
+ ret = devm_of_reserved_mem_device_init(dev);
+ if (ret)
dev_warn(dev, "failed to assign memory region: %d\n", ret);
- } else {
- ret = devm_add_action_or_reset(dev,
- mt8189_afe_release_reserved_mem,
- dev);
- if (ret)
- return ret;
- }
afe = devm_kzalloc(dev, sizeof(*afe), GFP_KERNEL);
if (!afe)
diff --git a/sound/soc/mediatek/mt8192/mt8192-afe-pcm.c b/sound/soc/mediatek/mt8192/mt8192-afe-pcm.c
index db0ae44a86af..e4ecd23df180 100644
--- a/sound/soc/mediatek/mt8192/mt8192-afe-pcm.c
+++ b/sound/soc/mediatek/mt8192/mt8192-afe-pcm.c
@@ -2155,11 +2155,6 @@ static const dai_register_cb dai_register_cbs[] = {
mt8192_dai_memif_register,
};
-static void mt8192_afe_release_reserved_mem(void *data)
-{
- of_reserved_mem_device_release(data);
-}
-
static int mt8192_afe_pcm_dev_probe(struct platform_device *pdev)
{
struct mtk_base_afe *afe;
@@ -2185,14 +2180,10 @@ static int mt8192_afe_pcm_dev_probe(struct platform_device *pdev)
afe->dev = dev;
- ret = of_reserved_mem_device_init(dev);
+ ret = devm_of_reserved_mem_device_init(dev);
if (ret) {
dev_info(dev, "no reserved memory found, pre-allocating buffers instead\n");
afe->preallocate_buffers = true;
- } else {
- ret = devm_add_action_or_reset(dev, mt8192_afe_release_reserved_mem, dev);
- if (ret)
- return ret;
}
/* init audio related clock */
diff --git a/sound/soc/mediatek/mt8195/mt8195-afe-pcm.c b/sound/soc/mediatek/mt8195/mt8195-afe-pcm.c
index bc0a63457cd7..52c3381e6766 100644
--- a/sound/soc/mediatek/mt8195/mt8195-afe-pcm.c
+++ b/sound/soc/mediatek/mt8195/mt8195-afe-pcm.c
@@ -3013,7 +3013,7 @@ static int mt8195_afe_pcm_dev_probe(struct platform_device *pdev)
struct reset_control *rstc;
int i, irq_id, ret;
- ret = of_reserved_mem_device_init(dev);
+ ret = devm_of_reserved_mem_device_init(dev);
if (ret)
return dev_err_probe(dev, ret, "failed to assign memory region\n");
diff --git a/sound/soc/mediatek/mt8196/mt8196-afe-pcm.c b/sound/soc/mediatek/mt8196/mt8196-afe-pcm.c
index a1ae8322d8b6..dcee037991aa 100644
--- a/sound/soc/mediatek/mt8196/mt8196-afe-pcm.c
+++ b/sound/soc/mediatek/mt8196/mt8196-afe-pcm.c
@@ -2309,11 +2309,6 @@ static const struct reg_sequence mt8196_cg_patch[] = {
{ AUDIO_TOP_CON4, 0x361c },
};
-static void mt8196_afe_release_reserved_mem(void *data)
-{
- of_reserved_mem_device_release(data);
-}
-
static int mt8196_afe_pcm_dev_probe(struct platform_device *pdev)
{
int ret, i;
@@ -2327,14 +2322,9 @@ static int mt8196_afe_pcm_dev_probe(struct platform_device *pdev)
if (ret)
return ret;
- ret = of_reserved_mem_device_init(dev);
- if (ret) {
+ ret = devm_of_reserved_mem_device_init(dev);
+ if (ret)
dev_err(dev, "failed to assign memory region: %d\n", ret);
- } else {
- ret = devm_add_action_or_reset(dev, mt8196_afe_release_reserved_mem, dev);
- if (ret)
- return ret;
- }
afe = devm_kzalloc(dev, sizeof(*afe), GFP_KERNEL);
if (!afe)
diff --git a/sound/soc/sof/mediatek/mt8186/mt8186.c b/sound/soc/sof/mediatek/mt8186/mt8186.c
index c1bea967737d..a5ccee87e684 100644
--- a/sound/soc/sof/mediatek/mt8186/mt8186.c
+++ b/sound/soc/sof/mediatek/mt8186/mt8186.c
@@ -49,7 +49,7 @@ static int platform_parse_resource(struct platform_device *pdev, void *data)
struct mtk_adsp_chip_info *adsp = data;
int ret;
- ret = of_reserved_mem_device_init(dev);
+ ret = devm_of_reserved_mem_device_init(dev);
if (ret) {
dev_err(dev, "of_reserved_mem_device_init failed\n");
return ret;
diff --git a/sound/soc/sof/mediatek/mt8195/mt8195.c b/sound/soc/sof/mediatek/mt8195/mt8195.c
index 4d6e9300a9c0..e4b6b6c18e02 100644
--- a/sound/soc/sof/mediatek/mt8195/mt8195.c
+++ b/sound/soc/sof/mediatek/mt8195/mt8195.c
@@ -49,7 +49,7 @@ static int platform_parse_resource(struct platform_device *pdev, void *data)
struct mtk_adsp_chip_info *adsp = data;
int ret;
- ret = of_reserved_mem_device_init(dev);
+ ret = devm_of_reserved_mem_device_init(dev);
if (ret) {
dev_err(dev, "of_reserved_mem_device_init failed\n");
return ret;
diff --git a/sound/soc/sprd/sprd-pcm-dma.c b/sound/soc/sprd/sprd-pcm-dma.c
index f509a4601de2..2d5ffbe17e81 100644
--- a/sound/soc/sprd/sprd-pcm-dma.c
+++ b/sound/soc/sprd/sprd-pcm-dma.c
@@ -459,10 +459,9 @@ static const struct snd_soc_component_driver sprd_soc_component = {
static int sprd_soc_platform_probe(struct platform_device *pdev)
{
- struct device_node *np = pdev->dev.of_node;
int ret;
- ret = of_reserved_mem_device_init_by_idx(&pdev->dev, np, 0);
+ ret = devm_of_reserved_mem_device_init(&pdev->dev);
if (ret)
dev_warn(&pdev->dev,
"no reserved DMA memory for audio platform device\n");