summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/device/device_util.c25
-rw-r--r--src/include/device/device.h1
2 files changed, 26 insertions, 0 deletions
diff --git a/src/device/device_util.c b/src/device/device_util.c
index e31ade56c0..859de319fa 100644
--- a/src/device/device_util.c
+++ b/src/device/device_util.c
@@ -775,6 +775,31 @@ void disable_children(struct bus *bus)
}
}
+/*
+ * Returns true if the device is an enabled bridge that has at least
+ * one enabled device on its secondary bus.
+ */
+bool dev_is_active_bridge(device_t dev)
+{
+ struct bus *link;
+ device_t child;
+
+ if (!dev || !dev->enabled)
+ return 0;
+
+ if (!dev->link_list || !dev->link_list->children)
+ return 0;
+
+ for (link = dev->link_list; link; link = link->next) {
+ for (child = link->children; child; child = child->sibling) {
+ if (child->enabled)
+ return 1;
+ }
+ }
+
+ return 0;
+}
+
static void resource_tree(struct device *root, int debug_level, int depth)
{
int i = 0;
diff --git a/src/include/device/device.h b/src/include/device/device.h
index 7b4fce36ea..5bc4d1c2f9 100644
--- a/src/include/device/device.h
+++ b/src/include/device/device.h
@@ -190,6 +190,7 @@ u32 dev_path_encode(device_t dev);
const char *bus_path(struct bus *bus);
void dev_set_enabled(device_t dev, int enable);
void disable_children(struct bus *bus);
+bool dev_is_active_bridge(device_t dev);
/* Option ROM helper functions */
void run_bios(struct device *dev, unsigned long addr);