Message ID | 20220308194704.14061-6-fnu.vikram@xilinx.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | dynamic node programming using overlay dtbo | expand |
Hi Vikram, > On 8 Mar 2022, at 19:46, Vikram Garhwal <fnu.vikram@xilinx.com> wrote: > > Add _dt_find_by_path() to find a matching node with path for a dt_device_node. > > Signed-off-by: Vikram Garhwal <fnu.vikram@xilinx.com> > --- > xen/common/device_tree.c | 10 ++++++++-- > xen/include/xen/device_tree.h | 9 +++++++++ > 2 files changed, 17 insertions(+), 2 deletions(-) > > diff --git a/xen/common/device_tree.c b/xen/common/device_tree.c > index f43d66a501..2e334f949e 100644 > --- a/xen/common/device_tree.c > +++ b/xen/common/device_tree.c > @@ -358,17 +358,23 @@ 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(struct dt_device_node *dt, > + const char *path) A function with a name starting with an underscore feels to me more an internal function rather than public, I suggest to find another name, maybe device_tree_find_node_by_path? > { > struct dt_device_node *np; > > - dt_for_each_device_node(dt_host, np) > + dt_for_each_device_node(dt, np) > if ( np->full_name && (dt_node_cmp(np->full_name, path) == 0) ) > break; > > return np; > } > > +struct dt_device_node *dt_find_node_by_path(const char *path) > +{ > + return _dt_find_node_by_path(dt_host, path); > +} This is public but it’s not declared in device_tree.h. Maybe this can become a static inline defined in the header? Cheers, Luca
diff --git a/xen/common/device_tree.c b/xen/common/device_tree.c index f43d66a501..2e334f949e 100644 --- a/xen/common/device_tree.c +++ b/xen/common/device_tree.c @@ -358,17 +358,23 @@ 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(struct dt_device_node *dt, + const char *path) { struct dt_device_node *np; - dt_for_each_device_node(dt_host, np) + dt_for_each_device_node(dt, np) if ( np->full_name && (dt_node_cmp(np->full_name, path) == 0) ) break; return np; } +struct dt_device_node *dt_find_node_by_path(const char *path) +{ + return _dt_find_node_by_path(dt_host, path); +} + int dt_find_node_by_gpath(XEN_GUEST_HANDLE(char) u_path, uint32_t u_plen, struct dt_device_node **node) { diff --git a/xen/include/xen/device_tree.h b/xen/include/xen/device_tree.h index 06d7866c10..9da32a851e 100644 --- a/xen/include/xen/device_tree.h +++ b/xen/include/xen/device_tree.h @@ -525,6 +525,15 @@ struct dt_device_node *dt_find_node_by_alias(const char *alias); */ struct dt_device_node *dt_find_node_by_path(const char *path); +/** + * _dt_find_node_by_path - Find a node matching a full DT path + * @dt_node: The device tree to search + * @path: The full path to match + * + * Returns a node pointer. + */ +struct dt_device_node *_dt_find_node_by_path(struct dt_device_node *dt, + const char *path); /** * dt_find_node_by_gpath - Same as dt_find_node_by_path but retrieve the
Add _dt_find_by_path() to find a matching node with path for a dt_device_node. Signed-off-by: Vikram Garhwal <fnu.vikram@xilinx.com> --- xen/common/device_tree.c | 10 ++++++++-- xen/include/xen/device_tree.h | 9 +++++++++ 2 files changed, 17 insertions(+), 2 deletions(-)