Skip to content

Commit 8918283

Browse files
morimotogeertu
authored andcommitted
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 <[email protected]> Tested-by: Yusuke Goda <[email protected]> Reviewed-by: Rob Herring <[email protected]> Reviewed-by: Geert Uytterhoeven <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Geert Uytterhoeven <[email protected]>
1 parent b5056ec commit 8918283

File tree

1 file changed

+18
-11
lines changed

1 file changed

+18
-11
lines changed

drivers/of/base.c

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -612,16 +612,9 @@ struct device_node *of_get_next_child(const struct device_node *node,
612612
}
613613
EXPORT_SYMBOL(of_get_next_child);
614614

615-
/**
616-
* of_get_next_available_child - Find the next available child node
617-
* @node: parent node
618-
* @prev: previous child of the parent node, or NULL to get first
619-
*
620-
* This function is like of_get_next_child(), except that it
621-
* automatically skips any disabled nodes (i.e. status = "disabled").
622-
*/
623-
struct device_node *of_get_next_available_child(const struct device_node *node,
624-
struct device_node *prev)
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 *))
625618
{
626619
struct device_node *next;
627620
unsigned long flags;
@@ -632,7 +625,7 @@ struct device_node *of_get_next_available_child(const struct device_node *node,
632625
raw_spin_lock_irqsave(&devtree_lock, flags);
633626
next = prev ? prev->sibling : node->child;
634627
for (; next; next = next->sibling) {
635-
if (!__of_device_is_available(next))
628+
if (!checker(next))
636629
continue;
637630
if (of_node_get(next))
638631
break;
@@ -641,6 +634,20 @@ struct device_node *of_get_next_available_child(const struct device_node *node,
641634
raw_spin_unlock_irqrestore(&devtree_lock, flags);
642635
return next;
643636
}
637+
638+
/**
639+
* of_get_next_available_child - Find the next available child node
640+
* @node: parent node
641+
* @prev: previous child of the parent node, or NULL to get first
642+
*
643+
* This function is like of_get_next_child(), except that it
644+
* automatically skips any disabled nodes (i.e. status = "disabled").
645+
*/
646+
struct device_node *of_get_next_available_child(const struct device_node *node,
647+
struct device_node *prev)
648+
{
649+
return of_get_next_status_child(node, prev, __of_device_is_available);
650+
}
644651
EXPORT_SYMBOL(of_get_next_available_child);
645652

646653
/**

0 commit comments

Comments
 (0)