summaryrefslogtreecommitdiff
path: root/hw/xfree86/os-support/bus/linuxPci.c
diff options
context:
space:
mode:
Diffstat (limited to 'hw/xfree86/os-support/bus/linuxPci.c')
-rw-r--r--hw/xfree86/os-support/bus/linuxPci.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/hw/xfree86/os-support/bus/linuxPci.c b/hw/xfree86/os-support/bus/linuxPci.c
index 4846ee0ed..6e33c2550 100644
--- a/hw/xfree86/os-support/bus/linuxPci.c
+++ b/hw/xfree86/os-support/bus/linuxPci.c
@@ -104,6 +104,7 @@ linuxPciOpenFile(PCITAG tag)
static int lbus,ldev,lfunc,fd = -1;
int bus, dev, func;
char file[32];
+ struct stat ignored;
bus = PCI_BUS_FROM_TAG(tag);
dev = PCI_DEV_FROM_TAG(tag);
@@ -111,12 +112,21 @@ linuxPciOpenFile(PCITAG tag)
if (fd == -1 || bus != lbus || dev != ldev || func != lfunc) {
if (fd != -1)
close(fd);
- if (bus < 256)
- sprintf(file, "/proc/bus/pci/%02x/%02x.%1x",
- bus, dev, func);
- else
- sprintf(file, "/proc/bus/pci/%04x/%02x.%1x",
- bus, dev, func);
+ if (bus < 256) {
+ if (stat("/proc/bus/pci/00", &ignored) < 0)
+ sprintf(file, "/proc/bus/pci/0000:%02x/%02x.%1x",
+ bus, dev, func);
+ else
+ sprintf(file, "/proc/bus/pci/%02x/%02x.%1x",
+ bus, dev, func);
+ } else {
+ if (stat("/proc/bus/pci/00", &ignored) < 0)
+ sprintf(file, "/proc/bus/pci/0000:%04x/%02x.%1x",
+ bus, dev, func);
+ else
+ sprintf(file, "/proc/bus/pci/%04x/%02x.%1x",
+ bus, dev, func);
+ }
fd = open(file,O_RDWR);
lbus = bus;
ldev = dev;