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> Reviewed-on: https://review.coreboot.org/c/coreboot/+/85989 Reviewed-by: Doug Anderson <dianders@chromium.org> Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Maximilian Brune <maximilian.brune@9elements.com>
This commit is contained in:
parent
5266191670
commit
cd912cf4a1
1 changed files with 4 additions and 2 deletions
|
|
@ -1050,7 +1050,8 @@ static struct device_tree_node *_dt_find_node(struct device_tree_node *parent,
|
|||
|
||||
/* 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 @@ struct device_tree_node *dt_find_node_by_path(struct device_tree *tree,
|
|||
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue