Re: [PATCH 05/10] dmaengine: fsldma: convert ioremap to devm_platform_ioremap_resource
From: Frank Li
Date: Fri Jun 05 2026 - 18:43:18 EST
On Fri, Jun 05, 2026 at 03:01:29PM -0700, Rosen Penev wrote:
>
> Convert of_iomap to devm_platform_ioremap_resource to let the devm
> framework handle unmapping. This allows removing the out_iounmap
> label, out_return label, and the explicit iounmap in both the probe
> error path and the remove function.
>
> The DGSR (fdev->regs) and per-channel registers (chan->regs) map
> physically distinct regions in all supported variants
> (EloPlus/Elo/Elo3), so there is no overlap risk.
>
> Assisted-by: opencode:big-pickle
> Signed-off-by: Rosen Penev <rosenp@xxxxxxxxx>
> ---
> drivers/dma/fsldma.c | 16 +++++-----------
> 1 file changed, 5 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/dma/fsldma.c b/drivers/dma/fsldma.c
> index 2efa16d12679..2a6a247761a4 100644
> --- a/drivers/dma/fsldma.c
> +++ b/drivers/dma/fsldma.c
> @@ -1229,19 +1229,17 @@ static int fsldma_of_probe(struct platform_device *op)
> fdev->addr_bits = (long)device_get_match_data(fdev->dev);
>
> /* ioremap the registers for use */
> - fdev->regs = of_iomap(op->dev.of_node, 0);
> - if (!fdev->regs) {
> + fdev->regs = devm_platform_ioremap_resource(op, 0);
> + if (IS_ERR(fdev->regs)) {
> dev_err(&op->dev, "unable to ioremap registers\n");
> - return -ENOMEM;
> + return PTR_ERR(fdev->regs);
> }
devm_platform_ioremap_resource() should print error message, so you can
remove above dev_err() also
Frank
>
> /* map the channel IRQ if it exists, but don't hookup the handler yet */
> fdev->irq = platform_get_irq_optional(op, 0);
> if (fdev->irq < 0) {
> - if (fdev->irq != -ENXIO) {
> - err = fdev->irq;
> - goto out_iounmap;
> - }
> + if (fdev->irq != -ENXIO)
> + return fdev->irq;
> fdev->irq = 0;
> }
>
> @@ -1309,8 +1307,6 @@ static int fsldma_of_probe(struct platform_device *op)
> if (fdev->chan[i])
> fsl_dma_chan_remove(fdev->chan[i]);
> }
> -out_iounmap:
> - iounmap(fdev->regs);
> return err;
> }
>
> @@ -1328,8 +1324,6 @@ static void fsldma_of_remove(struct platform_device *op)
> if (fdev->chan[i])
> fsl_dma_chan_remove(fdev->chan[i]);
> }
> -
> - iounmap(fdev->regs);
> }
>
> #ifdef CONFIG_PM
> --
> 2.54.0
>