mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-30 19:51:31 -04:00
of: fix reference counting in of_graph_get_endpoint_by_regs
The called of_graph_get_next_endpoint() already decrements the refcount
of the prev node, so it is wrong to do it again in the calling function.
Use the for_each_endpoint_of_node() helper to interate through the
endpoint OF nodes, which already does the right thing and simplifies
the code a bit.
Fixes: 8ccd0d0ca0
(of: add helper for getting endpoint node of specific identifiers)
Cc: [email protected]
Reported-by: David Jander <[email protected]>
Signed-off-by: Lucas Stach <[email protected]>
Acked-by: Philipp Zabel <[email protected]>
Signed-off-by: Rob Herring <[email protected]>
This commit is contained in:
parent
fc520f8b4f
commit
34276bb062
1 changed files with 2 additions and 9 deletions
|
|
@ -2342,20 +2342,13 @@ struct device_node *of_graph_get_endpoint_by_regs(
|
|||
const struct device_node *parent, int port_reg, int reg)
|
||||
{
|
||||
struct of_endpoint endpoint;
|
||||
struct device_node *node, *prev_node = NULL;
|
||||
|
||||
while (1) {
|
||||
node = of_graph_get_next_endpoint(parent, prev_node);
|
||||
of_node_put(prev_node);
|
||||
if (!node)
|
||||
break;
|
||||
struct device_node *node = NULL;
|
||||
|
||||
for_each_endpoint_of_node(parent, node) {
|
||||
of_graph_parse_endpoint(node, &endpoint);
|
||||
if (((port_reg == -1) || (endpoint.port == port_reg)) &&
|
||||
((reg == -1) || (endpoint.id == reg)))
|
||||
return node;
|
||||
|
||||
prev_node = node;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
|
|
|
|||
Loading…
Reference in a new issue