The common/device-tree/device-tree.c contains generic unflatten DT helpers API,
while dt_find_node_by_gpath() is specific for domctl (iommu) processing.
We move this function into drivers\passthrough\device_tree.c and make it
static, as it is used only there now.
Suggested-by: Grygorii Strashko <grygorii_strashko@epam.com>
Signed-off-by: Penny Zheng <penny.zheng@amd.com>
---
v4 -> v5:
- new commit
---
xen/common/device-tree/device-tree.c | 16 ---------------
xen/drivers/passthrough/device_tree.c | 28 +++++++++++++++++++++++++++
xen/include/xen/device_tree.h | 13 -------------
3 files changed, 28 insertions(+), 29 deletions(-)
diff --git a/xen/common/device-tree/device-tree.c b/xen/common/device-tree/device-tree.c
index 0b5375f151..d6cf417e94 100644
--- a/xen/common/device-tree/device-tree.c
+++ b/xen/common/device-tree/device-tree.c
@@ -371,22 +371,6 @@ struct dt_device_node *dt_find_node_by_path_from(struct dt_device_node *from,
return np;
}
-int dt_find_node_by_gpath(XEN_GUEST_HANDLE(char) u_path, uint32_t u_plen,
- struct dt_device_node **node)
-{
- char *path;
-
- path = safe_copy_string_from_guest(u_path, u_plen, PAGE_SIZE);
- if ( IS_ERR(path) )
- return PTR_ERR(path);
-
- *node = dt_find_node_by_path(path);
-
- xfree(path);
-
- return (*node == NULL) ? -ESRCH : 0;
-}
-
struct dt_device_node *dt_find_node_by_alias(const char *alias)
{
const struct dt_alias_prop *app;
diff --git a/xen/drivers/passthrough/device_tree.c b/xen/drivers/passthrough/device_tree.c
index f5850a2607..eb0c233977 100644
--- a/xen/drivers/passthrough/device_tree.c
+++ b/xen/drivers/passthrough/device_tree.c
@@ -16,6 +16,7 @@
*/
#include <xen/device_tree.h>
+#include <xen/err.h>
#include <xen/guest_access.h>
#include <xen/iommu.h>
#include <xen/lib.h>
@@ -318,6 +319,33 @@ int iommu_add_dt_device(struct dt_device_node *np)
return rc;
}
+/*
+ * dt_find_node_by_gpath - Same as dt_find_node_by_path but retrieve the
+ * path from the guest
+ *
+ * @u_path: Xen Guest handle to the buffer containing the path
+ * @u_plen: Length of the buffer
+ * @node: TODO
+ *
+ * Return 0 if succeed otherwise -errno
+ */
+static int dt_find_node_by_gpath(XEN_GUEST_HANDLE(char) u_path,
+ uint32_t u_plen,
+ struct dt_device_node **node)
+{
+ char *path;
+
+ path = safe_copy_string_from_guest(u_path, u_plen, PAGE_SIZE);
+ if ( IS_ERR(path) )
+ return PTR_ERR(path);
+
+ *node = dt_find_node_by_path(path);
+
+ xfree(path);
+
+ return (*node == NULL) ? -ESRCH : 0;
+}
+
int iommu_do_dt_domctl(struct xen_domctl *domctl, struct domain *d,
XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_domctl)
{
diff --git a/xen/include/xen/device_tree.h b/xen/include/xen/device_tree.h
index 06d7643622..241f269b57 100644
--- a/xen/include/xen/device_tree.h
+++ b/xen/include/xen/device_tree.h
@@ -550,19 +550,6 @@ 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
- * path from the guest
- *
- * @u_path: Xen Guest handle to the buffer containing the path
- * @u_plen: Length of the buffer
- * @node: TODO
- *
- * Return 0 if succeed otherwise -errno
- */
-int dt_find_node_by_gpath(XEN_GUEST_HANDLE(char) u_path, uint32_t u_plen,
- struct dt_device_node **node);
-
/**
* dt_get_parent - Get a node's parent if any
* @node: Node to get parent
--
2.34.1