summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNuno Sá <nuno.sa@analog.com>2025-11-04 19:22:28 +0300
committerVinod Koul <vkoul@kernel.org>2025-12-23 14:13:15 +0300
commitc23918bedc74a7809e6fa2fd1d09b860625a90b8 (patch)
tree20336b09826502641688134c9004055479a6aecd
parentb2440442ccb68479fa6d307917419983f3c87e83 (diff)
downloadlinux-c23918bedc74a7809e6fa2fd1d09b860625a90b8.tar.xz
dma: dma-axi-dmac: simplify axi_dmac_parse_dt()
Simplify axi_dmac_parse_dt() by using the cleanup device_node class for automatically releasing the of_node reference when going out of scope. Signed-off-by: Nuno Sá <nuno.sa@analog.com> base-commit: 398035178503bf662281bbffb4bebce1460a4bc5 change-id: 20251104-axi-dmac-fixes-and-improvs-e3ad512a329c Acked-by: Michael Hennerich <michael.hennerich@analog.com> Link: https://patch.msgid.link/20251104-axi-dmac-fixes-and-improvs-v1-4-3e6fd9328f72@analog.com Signed-off-by: Vinod Koul <vkoul@kernel.org>
-rw-r--r--drivers/dma/dma-axi-dmac.c13
1 files changed, 5 insertions, 8 deletions
diff --git a/drivers/dma/dma-axi-dmac.c b/drivers/dma/dma-axi-dmac.c
index 15c569449a28..045e9b9a90df 100644
--- a/drivers/dma/dma-axi-dmac.c
+++ b/drivers/dma/dma-axi-dmac.c
@@ -8,6 +8,7 @@
#include <linux/adi-axi-common.h>
#include <linux/bitfield.h>
+#include <linux/cleanup.h>
#include <linux/clk.h>
#include <linux/device.h>
#include <linux/dma-mapping.h>
@@ -927,22 +928,18 @@ static int axi_dmac_parse_chan_dt(struct device_node *of_chan,
static int axi_dmac_parse_dt(struct device *dev, struct axi_dmac *dmac)
{
- struct device_node *of_channels, *of_chan;
int ret;
- of_channels = of_get_child_by_name(dev->of_node, "adi,channels");
+ struct device_node *of_channels __free(device_node) = of_get_child_by_name(dev->of_node,
+ "adi,channels");
if (of_channels == NULL)
return -ENODEV;
- for_each_child_of_node(of_channels, of_chan) {
+ for_each_child_of_node_scoped(of_channels, of_chan) {
ret = axi_dmac_parse_chan_dt(of_chan, &dmac->chan);
- if (ret) {
- of_node_put(of_chan);
- of_node_put(of_channels);
+ if (ret)
return -EINVAL;
- }
}
- of_node_put(of_channels);
return 0;
}