diff options
author | Simon Glass <sjg@chromium.org> | 2022-09-06 20:27:24 -0600 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2022-09-29 22:43:43 -0400 |
commit | b7bd94f1a8a63cd4f947036e0d42ee2e23852d64 (patch) | |
tree | cb26f7ac2255dd93940b22859fea9f1b7b34759f /drivers/core | |
parent | 2187cb7e4aaae7a4ed7318a073b26dff462cb7a1 (diff) | |
download | u-boot-b7bd94f1a8a63cd4f947036e0d42ee2e23852d64.zip u-boot-b7bd94f1a8a63cd4f947036e0d42ee2e23852d64.tar.gz u-boot-b7bd94f1a8a63cd4f947036e0d42ee2e23852d64.tar.bz2 |
dm: core: Split ofnode_path_root() into two functions
This function turns out to be a little confusing since it looks up a path
and also registers the tree. Split it into two, one that gets the root
node and one that looks up a path, so the purpose is clear.
Registering the tree will happen in a function to be added in a later
patch, called oftree_from_fdt().
Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'drivers/core')
-rw-r--r-- | drivers/core/ofnode.c | 42 |
1 files changed, 37 insertions, 5 deletions
diff --git a/drivers/core/ofnode.c b/drivers/core/ofnode.c index b1ba8c5..7f6c47f 100644 --- a/drivers/core/ofnode.c +++ b/drivers/core/ofnode.c @@ -18,6 +18,26 @@ #include <linux/ioport.h> #include <asm/global_data.h> +/** + * ofnode_from_tree_offset() - get an ofnode from a tree offset (flat tree) + * + * Looks up the tree and returns an ofnode with the correct of_offset + * + * If @offset is < 0 then this returns an ofnode with that offset + * + * @tree: tree to check + * @offset: offset within that tree (can be < 0) + * @return node for that offset + */ +static ofnode ofnode_from_tree_offset(oftree tree, int offset) +{ + ofnode node; + + node.of_offset = offset; + + return node; +} + bool ofnode_name_eq(ofnode node, const char *name) { const char *node_name; @@ -640,15 +660,27 @@ ofnode ofnode_path(const char *path) return offset_to_ofnode(fdt_path_offset(gd->fdt_blob, path)); } -ofnode ofnode_path_root(oftree tree, const char *path) +ofnode oftree_root(oftree tree) { - if (of_live_active()) + if (of_live_active()) { + return np_to_ofnode(tree.np); + } else { + return ofnode_from_tree_offset(tree, 0); + } +} + +ofnode oftree_path(oftree tree, const char *path) +{ + if (of_live_active()) { return np_to_ofnode(of_find_node_opts_by_path(tree.np, path, NULL)); - else if (*path != '/' && tree.fdt != gd->fdt_blob) + } else if (*path != '/' && tree.fdt != gd->fdt_blob) { return ofnode_null(); /* Aliases only on control FDT */ - else - return offset_to_ofnode(fdt_path_offset(tree.fdt, path)); + } else { + int offset = fdt_path_offset(tree.fdt, path); + + return ofnode_from_tree_offset(tree, offset); + } } const void *ofnode_read_chosen_prop(const char *propname, int *sizep) |