Merge tag 'devicetree-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/glikely/linux
Pull devicetree changes from Grant Likely: "Here are the devicetree changes queued up for v4.1. Nothing really exciting here. Rob has another few commits for big-endian attached UARTs, but those will be sent in a separate merge request since they haven't been as thoroughly tested as this batch. Here are the highlights: - lots of unittest cleanup from Frank Rowand - bugfixes and updates to the of_graph code - tighten up of_get_mac_address() code - documentation updates" * tag 'devicetree-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/glikely/linux: of/unittest: Fix of_platform_depopulate test case of/unittest: early return from test skips tests of/unittest: breadcrumbs to reduce pain of future maintainers of/unittest: reduce checkpatch noise - line after declarations of/unittest: typo in error string of/unittest: add const where needed of_net: factor out repetitive code from of_get_mac_address() drivers/of: Add empty ranges quirk for PA-Semi of: Allow selection of OF_DYNAMIC and OF_OVERLAY if OF_UNITTEST of: Empty node & property flag accessors when !OF of: Explicitly include linux/types.h in of_graph.h dt-bindings: brcm: rationalize Broadcom documentation naming of/unittest: replace 'selftest' with 'unittest' Documentation: rename of_selftest.txt to of_unittest.txt Documentation: update the of_selftest.txt dt: OF_UNITTEST make dependency broken MAINTAINERS: Pantelis Antoniou device tree overlay maintainer of: Add of_graph_get_port_by_id function of: Add for_each_endpoint_of_node helper macro of: Decrement refcount of previous endpoint in of_graph_get_next_endpoint
This commit is contained in:
@@ -2108,14 +2108,45 @@ int of_graph_parse_endpoint(const struct device_node *node,
|
||||
}
|
||||
EXPORT_SYMBOL(of_graph_parse_endpoint);
|
||||
|
||||
/**
|
||||
* of_graph_get_port_by_id() - get the port matching a given id
|
||||
* @parent: pointer to the parent device node
|
||||
* @id: id of the port
|
||||
*
|
||||
* Return: A 'port' node pointer with refcount incremented. The caller
|
||||
* has to use of_node_put() on it when done.
|
||||
*/
|
||||
struct device_node *of_graph_get_port_by_id(struct device_node *parent, u32 id)
|
||||
{
|
||||
struct device_node *node, *port;
|
||||
|
||||
node = of_get_child_by_name(parent, "ports");
|
||||
if (node)
|
||||
parent = node;
|
||||
|
||||
for_each_child_of_node(parent, port) {
|
||||
u32 port_id = 0;
|
||||
|
||||
if (of_node_cmp(port->name, "port") != 0)
|
||||
continue;
|
||||
of_property_read_u32(port, "reg", &port_id);
|
||||
if (id == port_id)
|
||||
break;
|
||||
}
|
||||
|
||||
of_node_put(node);
|
||||
|
||||
return port;
|
||||
}
|
||||
EXPORT_SYMBOL(of_graph_get_port_by_id);
|
||||
|
||||
/**
|
||||
* of_graph_get_next_endpoint() - get next endpoint node
|
||||
* @parent: pointer to the parent device node
|
||||
* @prev: previous endpoint node, or NULL to get first
|
||||
*
|
||||
* Return: An 'endpoint' node pointer with refcount incremented. Refcount
|
||||
* of the passed @prev node is not decremented, the caller have to use
|
||||
* of_node_put() on it when done.
|
||||
* of the passed @prev node is decremented.
|
||||
*/
|
||||
struct device_node *of_graph_get_next_endpoint(const struct device_node *parent,
|
||||
struct device_node *prev)
|
||||
@@ -2151,12 +2182,6 @@ struct device_node *of_graph_get_next_endpoint(const struct device_node *parent,
|
||||
if (WARN_ONCE(!port, "%s(): endpoint %s has no parent node\n",
|
||||
__func__, prev->full_name))
|
||||
return NULL;
|
||||
|
||||
/*
|
||||
* Avoid dropping prev node refcount to 0 when getting the next
|
||||
* child below.
|
||||
*/
|
||||
of_node_get(prev);
|
||||
}
|
||||
|
||||
while (1) {
|
||||
|
Reference in New Issue
Block a user