linux: Use pci_device_get_parent_bridge instead of open-coding it

Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
Tested-by: Jeremy Huddleston <jeremyhu@apple.com>
Signed-off-by: Adam Jackson <ajax@redhat.com>
Reviewed-by: Jamey Sharp <jamey@minilop.net>
This commit is contained in:
Adam Jackson 2010-09-20 11:42:11 -04:00 committed by Jeremy Huddleston
parent 858fbbb40d
commit dd72b3c1f1

View File

@ -160,45 +160,6 @@ linuxPciOpenFile(struct pci_device *dev, Bool write)
#endif
/* This probably shouldn't be Linux-specific */
static struct 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;
}
static pointer
linuxMapPci(int ScreenNum, int Flags, struct pci_device *dev,
ADDRESS Base, unsigned long Size, int mmap_ioctl)
@ -283,7 +244,7 @@ linuxOpenLegacy(struct pci_device *dev, char *name)
return fd;
}
dev = get_parent_bridge(dev);
dev = pci_device_get_parent_bridge(dev);
}
return fd;