Julius Werner has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/85989?usp=email )
Change subject: commonlib/device_tree: Skip dt_read_cell_props() when not needed ......................................................................
commonlib/device_tree: Skip dt_read_cell_props() when not needed
dt_find_node() calls dt_read_cell_props() for every node it walks, but this is only actually necessary when the caller is interested in the `#address-cells` and `#size-cells` values and passed out-parameters to receive them. Most callers don't actually do that, and we scan through all properties needlessly on every node. This patch adds a fast path to skip that.
Change-Id: I114f824a7d88b0bac4a96aca3f7dced459503b02 Signed-off-by: Julius Werner jwerner@chromium.org --- M src/commonlib/device_tree.c 1 file changed, 4 insertions(+), 2 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/89/85989/1
diff --git a/src/commonlib/device_tree.c b/src/commonlib/device_tree.c index 2ee0316..a7007d9 100644 --- a/src/commonlib/device_tree.c +++ b/src/commonlib/device_tree.c @@ -1050,7 +1050,8 @@
/* Update #address-cells and #size-cells for the parent level (cells properties always count for the direct children of their node). */ - dt_read_cell_props(parent, addrcp, sizecp); + if (addrcp || sizecp) + dt_read_cell_props(parent, addrcp, sizecp);
/* Find the next node in the path, if it exists. */ list_for_each(node, parent->children, list_node) { @@ -1135,7 +1136,8 @@
if (path[0] == '/') { /* regular path */ if (path[1] == '\0') { /* special case: "/" is root node */ - dt_read_cell_props(tree->root, addrcp, sizecp); + if (addrcp || sizecp) + dt_read_cell_props(tree->root, addrcp, sizecp); return tree->root; }