diff options
author | Simon Glass | 2022-09-06 20:27:23 -0600 |
---|---|---|
committer | Tom Rini | 2022-09-29 22:43:43 -0400 |
commit | 2187cb7e4aaae7a4ed7318a073b26dff462cb7a1 (patch) | |
tree | 1f99048a80467776ab8c0d71f3a35f76f8318bda /drivers/core/ofnode.c | |
parent | 928d267aeea9406497c8060c03d3a0a78a8cbaa9 (diff) |
dm: core: Allow obtaining a node offset in the same tree
In some cases we want to obtain an ofnode in the same tree as a different
ofnode, such as when looking up a subnode. At present this is trivial,
since there is only one tree. When there are multiple trees, this
implementation will change.
Also move the ofnode_to_offset() function up higher in the header file,
since we will need to provide a different implementation with multiple
trees.
Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'drivers/core/ofnode.c')
-rw-r--r-- | drivers/core/ofnode.c | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/drivers/core/ofnode.c b/drivers/core/ofnode.c index 012cb8cddaa..b1ba8c5ab4c 100644 --- a/drivers/core/ofnode.c +++ b/drivers/core/ofnode.c @@ -278,7 +278,7 @@ ofnode ofnode_find_subnode(ofnode node, const char *subnode_name) } else { int ooffset = fdt_subnode_offset(ofnode_to_fdt(node), ofnode_to_offset(node), subnode_name); - subnode = offset_to_ofnode(ooffset); + subnode = noffset_to_ofnode(node, ooffset); } debug("%s\n", ofnode_valid(subnode) ? ofnode_get_name(subnode) : "<none>"); @@ -330,7 +330,7 @@ ofnode ofnode_first_subnode(ofnode node) if (ofnode_is_np(node)) return np_to_ofnode(node.np->child); - return offset_to_ofnode( + return noffset_to_ofnode(node, fdt_first_subnode(ofnode_to_fdt(node), ofnode_to_offset(node))); } @@ -340,7 +340,7 @@ ofnode ofnode_next_subnode(ofnode node) if (ofnode_is_np(node)) return np_to_ofnode(node.np->sibling); - return offset_to_ofnode( + return noffset_to_ofnode(node, fdt_next_subnode(ofnode_to_fdt(node), ofnode_to_offset(node))); } #endif /* !DM_INLINE_OFNODE */ @@ -1172,8 +1172,8 @@ ofnode ofnode_by_compatible(ofnode from, const char *compat) (struct device_node *)ofnode_to_np(from), NULL, compat)); } else { - return offset_to_ofnode(fdt_node_offset_by_compatible( - ofnode_to_fdt(from), + return noffset_to_ofnode(from, + fdt_node_offset_by_compatible(ofnode_to_fdt(from), ofnode_to_offset(from), compat)); } } @@ -1186,9 +1186,10 @@ ofnode ofnode_by_prop_value(ofnode from, const char *propname, (struct device_node *)ofnode_to_np(from), propname, propval, proplen)); } else { - return offset_to_ofnode(fdt_node_offset_by_prop_value( - ofnode_to_fdt(from), ofnode_to_offset(from), - propname, propval, proplen)); + return noffset_to_ofnode(from, + fdt_node_offset_by_prop_value(ofnode_to_fdt(from), + ofnode_to_offset(from), propname, propval, + proplen)); } } @@ -1342,7 +1343,7 @@ int ofnode_add_subnode(ofnode node, const char *name, ofnode *subnodep) } if (offset < 0) return -EINVAL; - subnode = offset_to_ofnode(offset); + subnode = noffset_to_ofnode(node, offset); } *subnodep = subnode; |