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

[XEN][PATCH v12 08/20] xen/device-tree: Add dt_find_node_by_path_from() to find nodes in device tree


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Vikram Garhwal <vikram.garhwal@xxxxxxx>
  • Date: Tue, 5 Sep 2023 18:16:18 -0700
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); 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=JIgawtLTJDYclMTRziV6+ukrPXqF+ozH3iEpHoQmI6c=; b=dzTsvZc9PcP6ZIbBY8Oou2Y4Wdr1Nm5Nhmt6klWU0E50DCTbYcUn5RdrndOOY524q16g6NeJNZccW5RBypV4ZEk2WxWNdfYsFx15geAmgkAWQfbj9PdXziFl7lwVvqxEOeanTWWEWOjvpIGhJZSFNpWmx+1YOrm0EkXO+J78NM6OYYF8RPRdGdEztVJHoPJEHfjMmjpJkaSbm59qoAofGy/GoE0+FKDAhJXFtGj1L9x1bms4srnyOmzu9YD+YdyD6cg6KEIZULlxlK1Mr2KBXqdDbNd6+6Mt6CeRSVQOQBi4EoGiGRbcgoBviOgmQK+hs7RJyQPlTiyXgxrtB65uCw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Bma/VP8gAET5qymQzVqSBwBwPI2pCwhUDxs/W0zwksb/wIfp7NaBkIStIFkDT013HKHTkjOuXq6Z5bgcj+duTqgdDsTwxw1YryEEMIoV68BK2xaW58vGgZfuREVpj9TdmddXctkuoWQSo1n3nY/KO7Fw+waTtuI/awzuNYWtmdiZrtnN6/ujGPk+IchToQGE35e2rNBxbC/gZ1aQPiVfjp5UG7rQSu54VoOYblk3rqaZzjwhvU8xQ4HLhkIiK0kXDzIghcP+72lBRzW+CETAG9DpQFW3a87gPbFbGW8IVlcdkbIxjX2MCXgsuFL5RWBSqjWQPmigglYqg911VYA0nw==
  • Cc: <vikram.garhwal@xxxxxxx>, <julien@xxxxxxx>, <michal.orzel@xxxxxxx>, <sstabellini@xxxxxxxxxx>
  • Delivery-date: Wed, 06 Sep 2023 01:16:51 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

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@xxxxxxx>
Reviewed-by: Michal Orzel <michal.orzel@xxxxxxx>
Acked-by: Stefano Stabellini <sstabellini@xxxxxxxxxx>

---
Changes from v10:
    Fix commit message with right function name.
Changes from v9:
    Fix indentation issues.

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 | 17 +++++++++++++++--
 2 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/xen/common/device_tree.c b/xen/common/device_tree.c
index b8ef1c7ae2..f38f51ec0b 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)
 {
     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 a518310a62..44d315c8ba 100644
--- a/xen/include/xen/device_tree.h
+++ b/xen/include/xen/device_tree.h
@@ -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
-- 
2.17.1




 


Rackspace

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