diff --git a/drivers/of/base.c b/drivers/of/base.c index b3718e7..8dd04ca 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c @@ -2210,3 +2210,25 @@ return np->parent; } EXPORT_SYMBOL(of_graph_get_remote_port); + +int of_graph_port_is_available(struct device_node *node) +{ + struct device_node *endpoint; + int available = 0; + + for_each_child_of_node(node, endpoint) { + struct device_node *remote_parent; + + remote_parent = of_graph_get_remote_port_parent(endpoint); + if (!remote_parent) + continue; + + if (!of_device_is_available(remote_parent)) + continue; + + available = 1; + } + + return available; +} +EXPORT_SYMBOL(of_graph_port_is_available); diff --git a/include/of_graph.h b/include/of_graph.h index fa037db..254dd2c 100644 --- a/include/of_graph.h +++ b/include/of_graph.h @@ -45,5 +45,6 @@ struct device_node *of_graph_get_remote_port_parent( const struct device_node *node); struct device_node *of_graph_get_remote_port(const struct device_node *node); +int of_graph_port_is_available(struct device_node *node); #endif /* __LINUX_OF_GRAPH_H */