Skip to content

Commit ac1e695

Browse files
morimotobroonie
authored andcommitted
of_graph: add of_graph_get_endpoint_count()
OF graph want to count its endpoint number, same as of_get_child_count(). This patch adds of_graph_get_endpoint_count() Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Acked-by: Rob Herring <robh@kernel.org> Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 0ef472a commit ac1e695

2 files changed

Lines changed: 18 additions & 0 deletions

File tree

‎drivers/of/base.c‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2559,6 +2559,18 @@ struct device_node *of_graph_get_remote_port(const struct device_node *node)
25592559
}
25602560
EXPORT_SYMBOL(of_graph_get_remote_port);
25612561

2562+
int of_graph_get_endpoint_count(const struct device_node *np)
2563+
{
2564+
struct device_node *endpoint;
2565+
int num = 0;
2566+
2567+
for_each_endpoint_of_node(np, endpoint)
2568+
num++;
2569+
2570+
return num;
2571+
}
2572+
EXPORT_SYMBOL(of_graph_get_endpoint_count);
2573+
25622574
/**
25632575
* of_graph_get_remote_node() - get remote parent device_node for given port/endpoint
25642576
* @node: pointer to parent device_node containing graph port/endpoint

‎include/linux/of_graph.h‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ struct of_endpoint {
4343
#ifdef CONFIG_OF
4444
int of_graph_parse_endpoint(const struct device_node *node,
4545
struct of_endpoint *endpoint);
46+
int of_graph_get_endpoint_count(const struct device_node *np);
4647
struct device_node *of_graph_get_port_by_id(struct device_node *node, u32 id);
4748
struct device_node *of_graph_get_next_endpoint(const struct device_node *parent,
4849
struct device_node *previous);
@@ -64,6 +65,11 @@ static inline int of_graph_parse_endpoint(const struct device_node *node,
6465
return -ENOSYS;
6566
}
6667

68+
static inline int of_graph_get_endpoint_count(const struct device_node *np)
69+
{
70+
return 0;
71+
}
72+
6773
static inline struct device_node *of_graph_get_port_by_id(
6874
struct device_node *node, u32 id)
6975
{

0 commit comments

Comments
 (0)