Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

of: Add of_get_next_status_child() and makes more generic of_get_next

Linux Kernel has of_get_next_available_child().
Add more generic of_get_next_status_child() to enable to use same
logic for other status.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Tested-by: Yusuke Goda <yusuke.goda.sx@renesas.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Link: https://lore.kernel.org/r/87bk9ugfb0.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>

authored by

Kuninori Morimoto and committed by
Geert Uytterhoeven
8918283a b5056ecf

+24 -17
+24 -17
drivers/of/base.c
··· 612 612 } 613 613 EXPORT_SYMBOL(of_get_next_child); 614 614 615 + static struct device_node *of_get_next_status_child(const struct device_node *node, 616 + struct device_node *prev, 617 + bool (*checker)(const struct device_node *)) 618 + { 619 + struct device_node *next; 620 + unsigned long flags; 621 + 622 + if (!node) 623 + return NULL; 624 + 625 + raw_spin_lock_irqsave(&devtree_lock, flags); 626 + next = prev ? prev->sibling : node->child; 627 + for (; next; next = next->sibling) { 628 + if (!checker(next)) 629 + continue; 630 + if (of_node_get(next)) 631 + break; 632 + } 633 + of_node_put(prev); 634 + raw_spin_unlock_irqrestore(&devtree_lock, flags); 635 + return next; 636 + } 637 + 615 638 /** 616 639 * of_get_next_available_child - Find the next available child node 617 640 * @node: parent node ··· 646 623 struct device_node *of_get_next_available_child(const struct device_node *node, 647 624 struct device_node *prev) 648 625 { 649 - struct device_node *next; 650 - unsigned long flags; 651 - 652 - if (!node) 653 - return NULL; 654 - 655 - raw_spin_lock_irqsave(&devtree_lock, flags); 656 - next = prev ? prev->sibling : node->child; 657 - for (; next; next = next->sibling) { 658 - if (!__of_device_is_available(next)) 659 - continue; 660 - if (of_node_get(next)) 661 - break; 662 - } 663 - of_node_put(prev); 664 - raw_spin_unlock_irqrestore(&devtree_lock, flags); 665 - return next; 626 + return of_get_next_status_child(node, prev, __of_device_is_available); 666 627 } 667 628 EXPORT_SYMBOL(of_get_next_available_child); 668 629