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

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


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Vikram Garhwal <vikram.garhwal@xxxxxxx>
  • Date: Thu, 1 Jun 2023 17:48:13 -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=KBFUC7bBO53GfeOJbg8EGgk2RkSd5j7Jb685AIjqUEE=; b=Rz8eoGSljynJbzelfqgzuA+n6xhqXDeeSYxNXAl43vLNBE19ZrHsPqnn1on7CtRoAAwGb9CDXsrBsPs1BVRArnxjelRbnWGHEcb0u0c0Xf0hhG7Sin+6I8HszWgUM81H7o5P6G4Iyw/1X7WSF9B85IOSXqjyCWi003++i+ftV6pn9QmJw4FZyTAZ8hIGOr8dXmwLZ3c0KIYhT1QQKY4bDnQ3CFo00h8jp1IbsC2DCkaROBq4wuCvaNFBJmC2TnpS/jzT5n6nJhDvU3lsU+EMzpvml6E9O4wz0wfq/zlYwifUE5wJdYS0+tEThIwtr3AM54GVnB6VRWiJ3pjJe3Bn9A==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=U11Fk2KsMWo+2lPhDY3uk8uCFVOius0ag6npTVCUO6xaQlpIMA16caiJetPB6TWUJW4QuMSRHD+JixfLjGkJ3P7l0keSvCEfC7HrJ3TEYgV/CsL+MlaT7vJnh/OULoeMxlhAucPDT151OT9lE1GfXbb1vt0HpTkliKVuw9N1NHqF4JL+M4x4MJLuKQG013wrO/N14IlVpAp9CK5WxQZug8LBYK0l5eX2sdXA9oMAm+ZgSRNehZSYqWmSWcStmEjv0JhtHsg8nvtM2c4fZzGnxVX7j4x43+280/wLJfEodtlT5ronu8Ff1jFoCxqBPzoGSWJbFi+MD2un+74mce5/mA==
  • Cc: <michal.orzel@xxxxxxx>, <sstabellini@xxxxxxxxxx>, <vikram.garhwal@xxxxxxx>, <jbeulich@xxxxxxxx>, Julien Grall <julien@xxxxxxx>
  • Delivery-date: Fri, 02 Jun 2023 00:48:58 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

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
    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 v6:
    Rename "dt_node" to "from"
---
 xen/common/device_tree.c      |  6 ++++--
 xen/include/xen/device_tree.h | 18 ++++++++++++++++--
 2 files changed, 20 insertions(+), 4 deletions(-)

diff --git a/xen/common/device_tree.c b/xen/common/device_tree.c
index 16b4b4e946..c5250a1644 100644
--- a/xen/common/device_tree.c
+++ b/xen/common/device_tree.c
@@ -358,11 +358,13 @@ 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 *
+                    device_tree_find_node_by_path(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 2c35c0d391..e239f7de26 100644
--- a/xen/include/xen/device_tree.h
+++ b/xen/include/xen/device_tree.h
@@ -561,13 +561,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
+ * device_tree_find_node_by_path - 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 *
+                    device_tree_find_node_by_path(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 device_tree_find_node_by_path(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®.