xen/device-tree: Add dt_find_node_by_path_from() to find nodes in device tree

Add dt_find_node_by_path_from() to find a matching node with path for a
dt_device_node.

Reason behind this function:
    Each time overlay nodes are added using .dtbo, a new fdt (memcpy of
    device_tree_flattened) is created and updated with overlay nodes. This
    updated fdt is further unflattened to a dt_host_new. Next, we need to find
    the overlay nodes in dt_host_new, find the overlay node's parent in dt_host
    and add the nodes as child under their parent in the dt_host. Thus we need
    this function to search for node in different unflattened device trees.

Also, make dt_find_node_by_path() static inline.

Signed-off-by: Vikram Garhwal <vikram.garhwal@amd.com>
Reviewed-by: Michal Orzel <michal.orzel@amd.com>
Acked-by: Stefano Stabellini <sstabellini@kernel.org>
This commit is contained in:
Vikram Garhwal authored and Stefano Stabellini committed 2023-09-05 18:25:44 -07:00
1 parent d434dc4ac1
commit 25141fed24
2 files changed
+18 -4

No files matched your search

+3 -2
View File
@@ -358,11 +358,12 @@ struct dt_device_node *dt_find_node_by_type(struct dt_device_node *from,
return np;
}
struct dt_device_node *dt_find_node_by_path(const char *path)
struct dt_device_node *dt_find_node_by_path_from(struct dt_device_node *from,
const char *path)
{
struct dt_device_node *np;
dt_for_each_device_node(dt_host, np)
dt_for_each_device_node(from, np)
if ( np->full_name && (dt_node_cmp(np->full_name, path) == 0) )
break;
+15 -2
View File
@@ -570,13 +570,26 @@ struct dt_device_node *dt_find_node_by_type(struct dt_device_node *from,
struct dt_device_node *dt_find_node_by_alias(const char *alias);
/**
* dt_find_node_by_path - Find a node matching a full DT path
* dt_find_node_by_path_from - Generic function to find a node matching the
* full DT path for any given unflatten device tree
* @from: The device tree node to start searching from
* @path: The full path to match
*
* Returns a node pointer.
*/
struct dt_device_node *dt_find_node_by_path(const char *path);
struct dt_device_node *dt_find_node_by_path_from(struct dt_device_node *from,
const char *path);
/**
* dt_find_node_by_path - Find a node matching a full DT path in dt_host
* @path: The full path to match
*
* Returns a node pointer.
*/
static inline struct dt_device_node *dt_find_node_by_path(const char *path)
{
return dt_find_node_by_path_from(dt_host, path);
}
/**
* dt_find_node_by_gpath - Same as dt_find_node_by_path but retrieve the
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.