]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
dmaengine: mv_xor: switch to for_each_child_of_node_scoped()
authorJavier Carrasco <javier.carrasco.cruz@gmail.com>
Fri, 11 Oct 2024 20:58:00 +0000 (22:58 +0200)
committerVinod Koul <vkoul@kernel.org>
Tue, 24 Dec 2024 10:15:50 +0000 (15:45 +0530)
Introduce the scoped variant of the loop to automatically release the
child node when it goes out of scope, which is more robust than the
non-scoped variant, and accounts for new early exits that could be added
in the future.

Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
Link: https://lore.kernel.org/r/20241011-dma_mv_xor_of_node_put-v1-2-3c2de819f463@gmail.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
drivers/dma/mv_xor.c

index 40b76b40bc30c22ea7aef9ff17fdb631f499620d..fa6e4646fdc29df4fd823922d416b63e621b8b9f 100644 (file)
@@ -1369,10 +1369,9 @@ static int mv_xor_probe(struct platform_device *pdev)
                return 0;
 
        if (pdev->dev.of_node) {
-               struct device_node *np;
                int i = 0;
 
-               for_each_child_of_node(pdev->dev.of_node, np) {
+               for_each_child_of_node_scoped(pdev->dev.of_node, np) {
                        struct mv_xor_chan *chan;
                        dma_cap_mask_t cap_mask;
                        int irq;
@@ -1388,7 +1387,6 @@ static int mv_xor_probe(struct platform_device *pdev)
                        irq = irq_of_parse_and_map(np, 0);
                        if (!irq) {
                                ret = -ENODEV;
-                               of_node_put(np);
                                goto err_channel_add;
                        }
 
@@ -1397,7 +1395,6 @@ static int mv_xor_probe(struct platform_device *pdev)
                        if (IS_ERR(chan)) {
                                ret = PTR_ERR(chan);
                                irq_dispose_mapping(irq);
-                               of_node_put(np);
                                goto err_channel_add;
                        }