#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>
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;
}