On Thu, Nov 16, 2017 at 09:39:20PM +0100, Mark Kettenis wrote:
> 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?
>
Makes sense, but i'd be tempted to rename to OF_getchildbyname().
tested on top of 6.2, and /dev/openprom did work with eeprom -p as always,
with bbb+cubie2+panda+wandboard.
slightly related, as the options thing in openprom was the only user on arm,
should it be "chosen" there instead of "options" ?
while there, maybe this too:
diff --git a/sys/dev/ofw/fdt.c b/sys/dev/ofw/fdt.c
index 54e1e01edbb..e9a717fae8f 100644
--- a/sys/dev/ofw/fdt.c
+++ b/sys/dev/ofw/fdt.c
@@ -336,7 +336,7 @@ fdt_node_property_int(void *node, char *name, int *out)
}
/*
- * Retrieves next node, skipping all the children nodes of the pointed node
+ * Retrieves the first child of an node.
*/
void *
fdt_child_node(void *node)
-Artturi
>
> 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 - 1.20
> +++ ofw/fdt.c 16 Nov 2017 20:28:27 -
> @@ -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;
>