summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/device/device_util.c13
-rw-r--r--src/include/device/device.h1
2 files changed, 14 insertions, 0 deletions
diff --git a/src/device/device_util.c b/src/device/device_util.c
index edf053d0dd..260c9b43ee 100644
--- a/src/device/device_util.c
+++ b/src/device/device_util.c
@@ -249,6 +249,19 @@ const char *dev_name(const struct device *dev)
return "unknown";
}
+/* Returns the PCI domain for the given PCI device */
+struct device *dev_get_pci_domain(struct device *dev)
+{
+ /* Walk up the tree up to the PCI domain */
+ while (dev && dev->bus && !is_root_device(dev)) {
+ dev = dev->bus->dev;
+ if (dev->path.type == DEVICE_PATH_DOMAIN)
+ return dev;
+ }
+
+ return NULL;
+}
+
/**
* Allocate 64 more resources to the free list.
*
diff --git a/src/include/device/device.h b/src/include/device/device.h
index 863299c01d..83588d4735 100644
--- a/src/include/device/device.h
+++ b/src/include/device/device.h
@@ -188,6 +188,7 @@ void assign_resources(struct bus *bus);
const char *dev_name(const struct device *dev);
const char *dev_path(const struct device *dev);
u32 dev_path_encode(const struct device *dev);
+struct device *dev_get_pci_domain(struct device *dev);
void dev_set_enabled(struct device *dev, int enable);
void disable_children(struct bus *bus);
bool dev_is_active_bridge(struct device *dev);