Skip to content

Commit c23918b

Browse files
nunojsavinodkoul
authored andcommitted
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: 3980351 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>
1 parent b244044 commit c23918b

1 file changed

Lines changed: 5 additions & 8 deletions

File tree

drivers/dma/dma-axi-dmac.c

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
#include <linux/adi-axi-common.h>
1010
#include <linux/bitfield.h>
11+
#include <linux/cleanup.h>
1112
#include <linux/clk.h>
1213
#include <linux/device.h>
1314
#include <linux/dma-mapping.h>
@@ -927,22 +928,18 @@ static int axi_dmac_parse_chan_dt(struct device_node *of_chan,
927928

928929
static int axi_dmac_parse_dt(struct device *dev, struct axi_dmac *dmac)
929930
{
930-
struct device_node *of_channels, *of_chan;
931931
int ret;
932932

933-
of_channels = of_get_child_by_name(dev->of_node, "adi,channels");
933+
struct device_node *of_channels __free(device_node) = of_get_child_by_name(dev->of_node,
934+
"adi,channels");
934935
if (of_channels == NULL)
935936
return -ENODEV;
936937

937-
for_each_child_of_node(of_channels, of_chan) {
938+
for_each_child_of_node_scoped(of_channels, of_chan) {
938939
ret = axi_dmac_parse_chan_dt(of_chan, &dmac->chan);
939-
if (ret) {
940-
of_node_put(of_chan);
941-
of_node_put(of_channels);
940+
if (ret)
942941
return -EINVAL;
943-
}
944942
}
945-
of_node_put(of_channels);
946943

947944
return 0;
948945
}

0 commit comments

Comments
 (0)