diff --git a/src/commonlib/device_tree.c b/src/commonlib/device_tree.c index c73e258ccb..2ee03162f1 100644 --- a/src/commonlib/device_tree.c +++ b/src/commonlib/device_tree.c @@ -1039,23 +1039,9 @@ void dt_read_cell_props(const struct device_tree_node *node, u32 *addrcp, } } -/* - * Find a node from a device tree path, relative to a parent node. - * - * @param parent The node from which to start the relative path lookup. - * @param path An array of path component strings that will be looked - * up in order to find the node. Must be terminated with - * a NULL pointer. Example: {'firmware', 'coreboot', NULL} - * @param addrcp Pointer that will be updated with any #address-cells - * value found in the path. May be NULL to ignore. - * @param sizecp Pointer that will be updated with any #size-cells - * value found in the path. May be NULL to ignore. - * @param create 1: Create node(s) if not found. 0: Return NULL instead. - * @return The found/created node, or NULL. - */ -struct device_tree_node *dt_find_node(struct device_tree_node *parent, - const char **path, u32 *addrcp, - u32 *sizecp, int create) +static struct device_tree_node *_dt_find_node(struct device_tree_node *parent, + const char **path, u32 *addrcp, + u32 *sizecp, int create) { struct device_tree_node *node, *found = NULL; @@ -1090,6 +1076,34 @@ struct device_tree_node *dt_find_node(struct device_tree_node *parent, return dt_find_node(found, path + 1, addrcp, sizecp, create); } +/* + * Find a node from a device tree path, relative to a parent node. + * + * @param parent The node from which to start the relative path lookup. + * @param path An array of path component strings that will be looked + * up in order to find the node. Must be terminated with + * a NULL pointer. Example: {'firmware', 'coreboot', NULL} + * @param addrcp Pointer that will be updated with any #address-cells + * value found in the path. May be NULL to ignore. + * @param sizecp Pointer that will be updated with any #size-cells + * value found in the path. May be NULL to ignore. + * @param create 1: Create node(s) if not found. 0: Return NULL instead. + * @return The found/created node, or NULL. + */ +struct device_tree_node *dt_find_node(struct device_tree_node *parent, + const char **path, u32 *addrcp, + u32 *sizecp, int create) +{ + /* Initialize cells to default values according to FDT spec. */ + if (addrcp) + *addrcp = 2; + + if (sizecp) + *sizecp = 1; + + return _dt_find_node(parent, path, addrcp, sizecp, create); +} + /* * Find a node in the tree from a string device tree path. *