diff options
author | 2016-03-17 14:10:29 +0000 | |
---|---|---|
committer | 2016-03-17 14:10:29 +0000 | |
commit | b9dd9f5596e7bc2849adcc902408a0b6315717e0 (patch) | |
tree | 1377032f3dd6afa4e67f2f40e3025d13d9a67f6f | |
parent | Replace curcpu_is_idle() by cpu_is_idle() and use it instead of rolling (diff) | |
download | wireguard-openbsd-b9dd9f5596e7bc2849adcc902408a0b6315717e0.tar.xz wireguard-openbsd-b9dd9f5596e7bc2849adcc902408a0b6315717e0.zip |
Do not iterate all over the tree if OF_parent() is called on the root
node. The root is the root, it has no parent.
From Patrick Wildt.
-rw-r--r-- | sys/dev/ofw/fdt.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/sys/dev/ofw/fdt.c b/sys/dev/ofw/fdt.c index c86df3e41d1..6810fdddfbc 100644 --- a/sys/dev/ofw/fdt.c +++ b/sys/dev/ofw/fdt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fdt.c,v 1.2 2016/03/07 10:49:03 mpi Exp $ */ +/* $OpenBSD: fdt.c,v 1.3 2016/03/17 14:10:29 mpi Exp $ */ /* * Copyright (c) 2009 Dariusz Swiderski <sfires@sfires.net> @@ -291,7 +291,7 @@ fdt_parent_node_recurse(void *pnode, void *child) { void *node = fdt_child_node(pnode); void *tmp; - + while (node && (node != child)) { if ((tmp = fdt_parent_node_recurse(node, child))) return tmp; @@ -308,6 +308,9 @@ fdt_parent_node(void *node) if (!tree_inited) return NULL; + if (node == pnode) + return NULL; + return fdt_parent_node_recurse(pnode, node); } @@ -428,7 +431,7 @@ int OF_parent(int handle) { void *node = (char *)tree.header + handle; - + node = fdt_parent_node(node); return node ? ((char *)node - (char *)tree.header) : 0; } |