* [PATCH] ASoC: fsl: dma: use platform helpers and devm cleanup
@ 2026-07-21 22:54 Rosen Penev
2026-07-30 12:19 ` Mark Brown
0 siblings, 1 reply; 2+ messages in thread
From: Rosen Penev @ 2026-07-21 22:54 UTC (permalink / raw)
To: linux-sound
Cc: Shengjiu Wang, Xiubo Li, Fabio Estevam, Nicolin Chen,
Liam Girdwood, Mark Brown, Jaroslav Kysela, Takashi Iwai,
Nathan Chancellor, Nick Desaulniers, Bill Wendling, Justin Stitt,
open list:FREESCALE SOC SOUND DRIVERS, open list,
open list:CLANG/LLVM BUILD SUPPORT:Keyword:b(?i:clang|llvm)b
Convert fsl_soc_dma_probe() to managed APIs. Replace the open-coded
of_address_to_resource()/of_iomap() of the DMA channel registers with
devm_platform_ioremap_resource(), and irq_of_parse_and_map() with
platform_get_irq() (which returns a negative errno instead of 0).
Switch the allocation to devm_kzalloc() and register the component via
the devm variant, dropping the now-unneeded error-path cleanup and the
manual fsl_soc_dma_remove().
The SSI node's register resource is still read via of_address_to_resource()
to compute the SSI FIFO physical addresses (dma->ssi_stx_phys /
ssi_srx_phys); only the DMA controller window is mapped.
The DMA controller register window is owned solely by this driver, so the
new region request from devm_platform_ioremap_resource() cannot conflict
with another claimant, and it is mapped exactly once (no double mapping).
The local channel pointer is declared as void __iomem * so the
devm_platform_ioremap_resource() result can be stored before assignment
to dma->channel.
No functional change; built for powerpc (allmodconfig + CONFIG_SND_SOC_FSL_DMA)
with LLVM=1 and sound/soc/fsl/fsl_dma.o compiles cleanly.
Assisted-by: opencode:hy3-free
Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
sound/soc/fsl/fsl_dma.c | 68 ++++++++++++++++-------------------------
1 file changed, 27 insertions(+), 41 deletions(-)
diff --git a/sound/soc/fsl/fsl_dma.c b/sound/soc/fsl/fsl_dma.c
index b12474880185..b1b341132dd6 100644
--- a/sound/soc/fsl/fsl_dma.c
+++ b/sound/soc/fsl/fsl_dma.c
@@ -18,8 +18,6 @@
#include <linux/delay.h>
#include <linux/gfp.h>
#include <linux/of_address.h>
-#include <linux/of_irq.h>
-#include <linux/of_platform.h>
#include <linux/list.h>
#include <linux/slab.h>
@@ -824,9 +822,34 @@ static int fsl_soc_dma_probe(struct platform_device *pdev)
struct device_node *np = pdev->dev.of_node;
struct device_node *ssi_np;
struct resource res;
+ void __iomem *channel;
const uint32_t *iprop;
+ int irq;
int ret;
+ channel = devm_platform_ioremap_resource(pdev, 0);
+ if (IS_ERR(channel))
+ return PTR_ERR(channel);
+
+ irq = platform_get_irq(pdev, 0);
+ if (irq < 0)
+ return irq;
+
+ dma = devm_kzalloc(&pdev->dev, sizeof(*dma), GFP_KERNEL);
+ if (!dma)
+ return -ENOMEM;
+
+ dma->dai.name = DRV_NAME;
+ dma->dai.open = fsl_dma_open;
+ dma->dai.close = fsl_dma_close;
+ dma->dai.hw_params = fsl_dma_hw_params;
+ dma->dai.hw_free = fsl_dma_hw_free;
+ dma->dai.pointer = fsl_dma_pointer;
+ dma->dai.pcm_new = fsl_dma_new;
+
+ dma->channel = channel;
+ dma->irq = irq;
+
/* Find the SSI node that points to us. */
ssi_np = find_ssi_node(np);
if (!ssi_np) {
@@ -842,55 +865,19 @@ static int fsl_soc_dma_probe(struct platform_device *pdev)
return ret;
}
- dma = kzalloc_obj(*dma);
- if (!dma) {
- of_node_put(ssi_np);
- return -ENOMEM;
- }
-
- dma->dai.name = DRV_NAME;
- dma->dai.open = fsl_dma_open;
- dma->dai.close = fsl_dma_close;
- dma->dai.hw_params = fsl_dma_hw_params;
- dma->dai.hw_free = fsl_dma_hw_free;
- dma->dai.pointer = fsl_dma_pointer;
- dma->dai.pcm_new = fsl_dma_new;
-
/* Store the SSI-specific information that we need */
dma->ssi_stx_phys = res.start + REG_SSI_STX0;
dma->ssi_srx_phys = res.start + REG_SSI_SRX0;
iprop = of_get_property(ssi_np, "fsl,fifo-depth", NULL);
+ of_node_put(ssi_np);
if (iprop)
dma->ssi_fifo_depth = be32_to_cpup(iprop);
else
/* Older 8610 DTs didn't have the fifo-depth property */
dma->ssi_fifo_depth = 8;
- of_node_put(ssi_np);
-
- ret = devm_snd_soc_register_component(&pdev->dev, &dma->dai, NULL, 0);
- if (ret) {
- dev_err(&pdev->dev, "could not register platform\n");
- kfree(dma);
- return ret;
- }
-
- dma->channel = of_iomap(np, 0);
- dma->irq = irq_of_parse_and_map(np, 0);
-
- dev_set_drvdata(&pdev->dev, dma);
-
- return 0;
-}
-
-static void fsl_soc_dma_remove(struct platform_device *pdev)
-{
- struct dma_object *dma = dev_get_drvdata(&pdev->dev);
-
- iounmap(dma->channel);
- irq_dispose_mapping(dma->irq);
- kfree(dma);
+ return devm_snd_soc_register_component(&pdev->dev, &dma->dai, NULL, 0);
}
static const struct of_device_id fsl_soc_dma_ids[] = {
@@ -905,7 +892,6 @@ static struct platform_driver fsl_soc_dma_driver = {
.of_match_table = fsl_soc_dma_ids,
},
.probe = fsl_soc_dma_probe,
- .remove = fsl_soc_dma_remove,
};
module_platform_driver(fsl_soc_dma_driver);
--
2.55.0
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] ASoC: fsl: dma: use platform helpers and devm cleanup
2026-07-21 22:54 [PATCH] ASoC: fsl: dma: use platform helpers and devm cleanup Rosen Penev
@ 2026-07-30 12:19 ` Mark Brown
0 siblings, 0 replies; 2+ messages in thread
From: Mark Brown @ 2026-07-30 12:19 UTC (permalink / raw)
To: linux-sound, Rosen Penev
Cc: Shengjiu Wang, Xiubo Li, Fabio Estevam, Nicolin Chen,
Liam Girdwood, Jaroslav Kysela, Takashi Iwai, Nathan Chancellor,
Nick Desaulniers, Bill Wendling, Justin Stitt, linuxppc-dev,
linux-kernel, llvm
On Tue, 21 Jul 2026 15:54:42 -0700, Rosen Penev wrote:
> ASoC: fsl: dma: use platform helpers and devm cleanup
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-7.3
Thanks!
[1/1] ASoC: fsl: dma: use platform helpers and devm cleanup
https://git.kernel.org/broonie/sound/c/522d7baa39e9
All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying
to this mail.
Thanks,
Mark
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-07-30 15:50 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-21 22:54 [PATCH] ASoC: fsl: dma: use platform helpers and devm cleanup Rosen Penev
2026-07-30 12:19 ` Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox