The current FDT implementation is fairly useless since it doesn't
actually look at the child nodes.  The macppc implementation walks the
entire tree.  But all current use cases of this function only look at
children of the passed node.  Diff below makes OF_getnodebyname()
behave like that.

ok?


Index: ofw/fdt.c
===================================================================
RCS file: /cvs/src/sys/dev/ofw/fdt.c,v
retrieving revision 1.20
diff -u -p -r1.20 fdt.c
--- ofw/fdt.c   12 Mar 2017 11:44:42 -0000      1.20
+++ ofw/fdt.c   16 Nov 2017 20:28:27 -0000
@@ -773,11 +773,9 @@ OF_getnodebyname(int handle, const char 
        if (handle == 0)
                node = fdt_find_node("/");
 
-       while (node) {
+       for (node = fdt_child_node(node); node; node = fdt_next_node(node)) {
                if (strcmp(name, fdt_node_name(node)) == 0)
                        break;
-
-               node = fdt_next_node(node);
        }
 
        return node ? ((char *)node - (char *)tree.header) : 0;

Reply via email to