Skip to content

Commit b8ba92b

Browse files
committed
Merge branch 'topic/of-graph-base' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound into dt/property-move
OF graph changes for ALSA conflict with the move of graph functions into property.c.
2 parents d20dc14 + ac1e695 commit b8ba92b

3 files changed

Lines changed: 73 additions & 10 deletions

File tree

‎drivers/of/base.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1149,6 +1149,7 @@ int of_phandle_iterator_init(struct of_phandle_iterator *it,
11491149

11501150
return 0;
11511151
}
1152+
EXPORT_SYMBOL_GPL(of_phandle_iterator_init);
11521153

11531154
int of_phandle_iterator_next(struct of_phandle_iterator *it)
11541155
{
@@ -1218,6 +1219,7 @@ int of_phandle_iterator_next(struct of_phandle_iterator *it)
12181219

12191220
return -EINVAL;
12201221
}
1222+
EXPORT_SYMBOL_GPL(of_phandle_iterator_next);
12211223

12221224
int of_phandle_iterator_args(struct of_phandle_iterator *it,
12231225
uint32_t *args,

‎drivers/of/property.c‎

Lines changed: 50 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -683,6 +683,41 @@ struct device_node *of_graph_get_endpoint_by_regs(
683683
}
684684
EXPORT_SYMBOL(of_graph_get_endpoint_by_regs);
685685

686+
/**
687+
* of_graph_get_remote_endpoint() - get remote endpoint node
688+
* @node: pointer to a local endpoint device_node
689+
*
690+
* Return: Remote endpoint node associated with remote endpoint node linked
691+
* to @node. Use of_node_put() on it when done.
692+
*/
693+
struct device_node *of_graph_get_remote_endpoint(const struct device_node *node)
694+
{
695+
/* Get remote endpoint node. */
696+
return of_parse_phandle(node, "remote-endpoint", 0);
697+
}
698+
EXPORT_SYMBOL(of_graph_get_remote_endpoint);
699+
700+
/**
701+
* of_graph_get_port_parent() - get port's parent node
702+
* @node: pointer to a local endpoint device_node
703+
*
704+
* Return: device node associated with endpoint node linked
705+
* to @node. Use of_node_put() on it when done.
706+
*/
707+
struct device_node *of_graph_get_port_parent(struct device_node *node)
708+
{
709+
unsigned int depth;
710+
711+
/* Walk 3 levels up only if there is 'ports' node. */
712+
for (depth = 3; depth && node; depth--) {
713+
node = of_get_next_parent(node);
714+
if (depth == 2 && of_node_cmp(node->name, "ports"))
715+
break;
716+
}
717+
return node;
718+
}
719+
EXPORT_SYMBOL(of_graph_get_port_parent);
720+
686721
/**
687722
* of_graph_get_remote_port_parent() - get remote port's parent node
688723
* @node: pointer to a local endpoint device_node
@@ -694,18 +729,11 @@ struct device_node *of_graph_get_remote_port_parent(
694729
const struct device_node *node)
695730
{
696731
struct device_node *np;
697-
unsigned int depth;
698732

699733
/* Get remote endpoint node. */
700-
np = of_parse_phandle(node, "remote-endpoint", 0);
734+
np = of_graph_get_remote_endpoint(node);
701735

702-
/* Walk 3 levels up only if there is 'ports' node. */
703-
for (depth = 3; depth && np; depth--) {
704-
np = of_get_next_parent(np);
705-
if (depth == 2 && of_node_cmp(np->name, "ports"))
706-
break;
707-
}
708-
return np;
736+
return of_graph_get_port_parent(np);
709737
}
710738
EXPORT_SYMBOL(of_graph_get_remote_port_parent);
711739

@@ -721,13 +749,25 @@ struct device_node *of_graph_get_remote_port(const struct device_node *node)
721749
struct device_node *np;
722750

723751
/* Get remote endpoint node. */
724-
np = of_parse_phandle(node, "remote-endpoint", 0);
752+
np = of_graph_get_remote_endpoint(node);
725753
if (!np)
726754
return NULL;
727755
return of_get_next_parent(np);
728756
}
729757
EXPORT_SYMBOL(of_graph_get_remote_port);
730758

759+
int of_graph_get_endpoint_count(const struct device_node *np)
760+
{
761+
struct device_node *endpoint;
762+
int num = 0;
763+
764+
for_each_endpoint_of_node(np, endpoint)
765+
num++;
766+
767+
return num;
768+
}
769+
EXPORT_SYMBOL(of_graph_get_endpoint_count);
770+
731771
/**
732772
* of_graph_get_remote_node() - get remote parent device_node for given port/endpoint
733773
* @node: pointer to parent device_node containing graph port/endpoint

‎include/linux/of_graph.h‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,15 @@ 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);
4950
struct device_node *of_graph_get_endpoint_by_regs(
5051
const struct device_node *parent, int port_reg, int reg);
52+
struct device_node *of_graph_get_remote_endpoint(
53+
const struct device_node *node);
54+
struct device_node *of_graph_get_port_parent(struct device_node *node);
5155
struct device_node *of_graph_get_remote_port_parent(
5256
const struct device_node *node);
5357
struct device_node *of_graph_get_remote_port(const struct device_node *node);
@@ -61,6 +65,11 @@ static inline int of_graph_parse_endpoint(const struct device_node *node,
6165
return -ENOSYS;
6266
}
6367

68+
static inline int of_graph_get_endpoint_count(const struct device_node *np)
69+
{
70+
return 0;
71+
}
72+
6473
static inline struct device_node *of_graph_get_port_by_id(
6574
struct device_node *node, u32 id)
6675
{
@@ -80,6 +89,18 @@ static inline struct device_node *of_graph_get_endpoint_by_regs(
8089
return NULL;
8190
}
8291

92+
static inline struct device_node *of_graph_get_remote_endpoint(
93+
const struct device_node *node)
94+
{
95+
return NULL;
96+
}
97+
98+
static inline struct device_node *of_graph_get_port_parent(
99+
struct device_node *node)
100+
{
101+
return NULL;
102+
}
103+
83104
static inline struct device_node *of_graph_get_remote_port_parent(
84105
const struct device_node *node)
85106
{

0 commit comments

Comments
 (0)