Module Name:    xsrc
Committed By:   mrg
Date:           Sat May 22 10:29:41 UTC 2010

Modified Files:
        xsrc/external/mit/libpciaccess/dist/src: common_bridge.c
Removed Files:
        xsrc/external/mit/libpciaccess/dist: NEWS

Log Message:
merge libpciaccess 0.11.0


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.1 -r0 xsrc/external/mit/libpciaccess/dist/NEWS
cvs rdiff -u -r1.3 -r1.4 \
    xsrc/external/mit/libpciaccess/dist/src/common_bridge.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: xsrc/external/mit/libpciaccess/dist/src/common_bridge.c
diff -u xsrc/external/mit/libpciaccess/dist/src/common_bridge.c:1.3 xsrc/external/mit/libpciaccess/dist/src/common_bridge.c:1.4
--- xsrc/external/mit/libpciaccess/dist/src/common_bridge.c:1.3	Mon Nov  9 06:32:25 2009
+++ xsrc/external/mit/libpciaccess/dist/src/common_bridge.c	Sat May 22 10:29:41 2010
@@ -325,3 +325,43 @@
 
     return 0;
 }
+
+#define PCI_CLASS_BRIDGE 0x06
+#define PCI_SUBCLASS_BRIDGE_PCI 0x04
+
+struct pci_device *
+pci_device_get_parent_bridge(struct pci_device *dev)
+{
+    struct pci_id_match bridge_match = {
+        PCI_MATCH_ANY, PCI_MATCH_ANY, PCI_MATCH_ANY, PCI_MATCH_ANY,
+        (PCI_CLASS_BRIDGE << 16) | (PCI_SUBCLASS_BRIDGE_PCI << 8),
+        0
+    };
+
+    struct pci_device *bridge;
+    struct pci_device_iterator *iter;
+
+    if (dev == NULL)
+        return NULL;
+
+    iter = pci_id_match_iterator_create(& bridge_match);
+    if (iter == NULL)
+        return NULL;
+
+    while ((bridge = pci_device_next(iter)) != NULL) {
+        if (bridge->domain == dev->domain) {
+            const struct pci_bridge_info *info =
+                pci_device_get_bridge_info(bridge);
+
+            if (info != NULL) {
+                if (info->secondary_bus == dev->bus) {
+                    break;
+                }
+            }
+        }
+    }
+
+    pci_iterator_destroy(iter);
+
+    return bridge;
+}

Reply via email to