|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [xen staging] xen/device-tree: Add dt_get_pci_domain_nr helper
commit f01be299050969f842fbc353f3d465b92979d3d7
Author: Rahul Singh <rahul.singh@xxxxxxx>
AuthorDate: Tue Sep 28 19:18:17 2021 +0100
Commit: Stefano Stabellini <stefano.stabellini@xxxxxxxxxx>
CommitDate: Thu Sep 30 18:26:13 2021 -0700
xen/device-tree: Add dt_get_pci_domain_nr helper
Based Linux commit 41e5c0f81d3e676d671d96a0a1fafb27abfbd9d7
Import the Linux helper of_get_pci_domain_nr. This function will try to
obtain the host bridge domain number by finding a property called
"linux,pci-domain" of the given device node.
Signed-off-by: Rahul Singh <rahul.singh@xxxxxxx>
Reviewed-by: Stefano Stabellini <sstabellini@xxxxxxxxxx>
Reviewed-by: Bertrand Marquis <bertrand.marquis@xxxxxxx>
---
xen/common/device_tree.c | 12 ++++++++++++
xen/include/xen/device_tree.h | 17 +++++++++++++++++
2 files changed, 29 insertions(+)
diff --git a/xen/common/device_tree.c b/xen/common/device_tree.c
index 53160d61f8..ea93da1725 100644
--- a/xen/common/device_tree.c
+++ b/xen/common/device_tree.c
@@ -2183,6 +2183,18 @@ void __init dt_unflatten_host_device_tree(void)
dt_alias_scan();
}
+int dt_get_pci_domain_nr(struct dt_device_node *node)
+{
+ u32 domain;
+ int error;
+
+ error = dt_property_read_u32(node, "linux,pci-domain", &domain);
+ if ( !error )
+ return -EINVAL;
+
+ return (u16)domain;
+}
+
/*
* Local variables:
* mode: C
diff --git a/xen/include/xen/device_tree.h b/xen/include/xen/device_tree.h
index 3ffe3eb3d2..2297c59ce6 100644
--- a/xen/include/xen/device_tree.h
+++ b/xen/include/xen/device_tree.h
@@ -832,6 +832,23 @@ int dt_count_phandle_with_args(const struct dt_device_node
*np,
const char *list_name,
const char *cells_name);
+/**
+ * dt_get_pci_domain_nr - Find the host bridge domain number
+ * of the given device node.
+ * @node: Device tree node with the domain information.
+ *
+ * This function will try to obtain the host bridge domain number by finding
+ * a property called "linux,pci-domain" of the given device node.
+ *
+ * Return:
+ * * > 0 - On success, an associated domain number.
+ * * -EINVAL - The property "linux,pci-domain" does not exist.
+ *
+ * Returns the associated domain number from DT in the range [0-0xffff], or
+ * a negative value if the required property is not found.
+ */
+int dt_get_pci_domain_nr(struct dt_device_node *node);
+
#ifdef CONFIG_DEVICE_TREE_DEBUG
#define dt_dprintk(fmt, args...) \
printk(XENLOG_DEBUG fmt, ## args)
--
generated by git-patchbot for /home/xen/git/xen.git#staging
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |