[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [XEN][PATCH v9 08/19] xen/device-tree: Add device_tree_find_node_by_path() to find nodes in device tree


  • To: Julien Grall <julien@xxxxxxx>
  • From: Vikram Garhwal <vikram.garhwal@xxxxxxx>
  • Date: Thu, 24 Aug 2023 21:08:01 -0700
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=JaYgviboBmkdY9fB+dvzdCj/khpGJqJRqXrSgA+ERrE=; b=KREcUjyJd1MRDUtvzv4HY1i0iY2zDZ13opqyaHxgQ2s700QK0QS5GdH2sLtm9ws39YYIXR+u51v2FGUXk+5dGk740CormPLFkomewzJTYSLfK8fp9tT6LTF5jSyvMcAXNVuS65FN1hXcPb1Y/x+D3tcpHB6WYCBnA6UPxc1a8pTvxJ3GAWfelYFxZillZzsQCakktPMo5h5mqGnDIHjaXiMAC28+iO16YCkv9YlXrxKOA0faY13qKI1rfnT6td3fihWOdGO7idmDDYihj4T6uuPiFLWvLoDpw1wf6ACtYybg72ulscSwiznw/JjfQEN3p/Uzd92WCebr6q2c+8ejEQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RFGWoKO875yidIljnY7uCSZBuwT+9nafdB33tc4tNRrWQu+GEzwnsEsXJ60O86VsGHoUjw4m6W4cFq+7I3PC69wQ6uDEAowjCJhRA6jPn6Y7LtuQxOPgAT0w9uhW47khIy9Ola7WcH4CadVlWwq/79eTojlup2ftLhTJsQDL7sVnL5dlQL8pC5F54qFAlP+YgsiBena8vcvZ6AJ7N812AWvUbo2/4CovFk8wzNOrQSbssXEzgzxtLR3y23bDIc4t66pYEKL28yE8B0YvvXo1mILYygayUNI8sEWokCBA8eTbjqOEQcL2IHGAsUyAzEE/uXwGh0rD1Sz6b4TdFynM2w==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com;
  • Cc: xen-devel@xxxxxxxxxxxxxxxxxxxx, michal.orzel@xxxxxxx, sstabellini@xxxxxxxxxx, jbeulich@xxxxxxxx
  • Delivery-date: Fri, 25 Aug 2023 04:08:28 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Hi Julien,
On Tue, Aug 22, 2023 at 08:21:17PM +0100, Julien Grall wrote:
> Hi Vikram,
> 
> On 19/08/2023 01:28, Vikram Garhwal wrote:
> > Add device_tree_find_node_by_path() 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
> 
> Typo: missing space before (.
> 
> >      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@xxxxxxx>
> 
> > ---
> > Changes from v7:
> >      Rename device_tree_find_node_by_path() to dt_find_node_by_path_from().
> >      Fix indentation.
> > ---
> > ---
> >   xen/common/device_tree.c      |  5 +++--
> >   xen/include/xen/device_tree.h | 18 ++++++++++++++++--
> >   2 files changed, 19 insertions(+), 4 deletions(-)
> > 
> > diff --git a/xen/common/device_tree.c b/xen/common/device_tree.c
> > index 67e9b6de3e..0f10037745 100644
> > --- a/xen/common/device_tree.c
> > +++ b/xen/common/device_tree.c
> > @@ -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)
> 
> Any change this both 'from' and the return can be const?
Doing this will also need changes in dt_find_node_by_path() and
dt_for_each_device_node(). This function calls both of these.
> 
> >   {
> >       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;
> > diff --git a/xen/include/xen/device_tree.h b/xen/include/xen/device_tree.h
> > index 5941599eff..e507658b23 100644
> > --- a/xen/include/xen/device_tree.h
> > +++ b/xen/include/xen/device_tree.h
> > @@ -568,13 +568,27 @@ 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);
> 
> Coding style: The indentation look rather odd. I am not sure it will render
> properly here. But one style that is closer to the rest of the file and Xen
> is:
> 
> struct dt_device_node *dt_find_node_by_path_from(struct dt_device_node
> *from,
>                                                  const char *path);
> 
> Where the return type, function name and first parameter is one line and the
> second parameter is on the second line with the type aligned with the type
> of the first parameter.
Will do!
> 
> > +/**
> > + * 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
> 
> Cheers,
> 
> -- 
> Julien Grall



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.