Re: [PATCHv3 09/15] dmaengine: fsldma: use devm for kzalloc()
From: Frank Li <hidden>
Date: 2026-06-10 01:57:28
Also in:
dmaengine, lkml, llvm
On Tue, Jun 09, 2026 at 03:19:20PM -0700, Rosen Penev wrote: nit: subject dmaengine: fsldma: use devm_kzalloc() to simplify code.
quoted hunk ↗ jump to hunk
Convert fdev allocation from kzalloc_obj() to devm_kzalloc() to simplify the probe error and remove paths by dropping the explicit kfree. Assisted-by: opencode:big-pickle Signed-off-by: Rosen Penev <redacted> --- drivers/dma/fsldma.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-)diff --git a/drivers/dma/fsldma.c b/drivers/dma/fsldma.c index eba194d64105..dac12de06ef5 100644 --- a/drivers/dma/fsldma.c +++ b/drivers/dma/fsldma.c@@ -1222,18 +1222,17 @@ static void fsldma_device_release(struct dma_device *dma_dev); static int fsldma_of_probe(struct platform_device *op) { + struct device *dev = &op->dev; struct fsldma_device *fdev; struct device_node *child; unsigned int i; int err; - fdev = kzalloc_obj(*fdev); - if (!fdev) { - err = -ENOMEM; - goto out_return; - } + fdev = devm_kzalloc(dev, sizeof(*fdev), GFP_KERNEL); + if (!fdev) + return -ENOMEM; - fdev->dev = &op->dev; + fdev->dev = dev;
not big beanfit add dev in this patch. If you like, create new patch, replace all op->dev with dev.
quoted hunk ↗ jump to hunk
INIT_LIST_HEAD(&fdev->common.channels); /* The DMA address bits supported for this device. */ fdev->addr_bits = (long)device_get_match_data(fdev->dev);@@ -1242,8 +1241,7 @@ static int fsldma_of_probe(struct platform_device *op) fdev->regs = of_iomap(op->dev.of_node, 0); if (!fdev->regs) { dev_err(&op->dev, "unable to ioremap registers\n"); - err = -ENOMEM; - goto out_free; + return -ENOMEM;
return dev_err_probe() Frank
quoted hunk ↗ jump to hunk
} /* map the channel IRQ if it exists, but don't hookup the handler yet */@@ -1325,9 +1323,6 @@ static int fsldma_of_probe(struct platform_device *op) } out_iounmap: iounmap(fdev->regs); -out_free: - kfree(fdev); -out_return: return err; }@@ -1361,7 +1356,6 @@ static void fsldma_of_remove(struct platform_device *op) } iounmap(fdev->regs); - kfree(fdev); } #ifdef CONFIG_PM --2.54.0