Lines 104-109
Link Here
|
104 |
static int lbus,ldev,lfunc,fd = -1; |
104 |
static int lbus,ldev,lfunc,fd = -1; |
105 |
int bus, dev, func; |
105 |
int bus, dev, func; |
106 |
char file[32]; |
106 |
char file[32]; |
|
|
107 |
struct stat ignored; |
107 |
|
108 |
|
108 |
bus = PCI_BUS_FROM_TAG(tag); |
109 |
bus = PCI_BUS_FROM_TAG(tag); |
109 |
dev = PCI_DEV_FROM_TAG(tag); |
110 |
dev = PCI_DEV_FROM_TAG(tag); |
Lines 111-122
Link Here
|
111 |
if (fd == -1 || bus != lbus || dev != ldev || func != lfunc) { |
112 |
if (fd == -1 || bus != lbus || dev != ldev || func != lfunc) { |
112 |
if (fd != -1) |
113 |
if (fd != -1) |
113 |
close(fd); |
114 |
close(fd); |
114 |
if (bus < 256) |
115 |
if (bus < 256) { |
115 |
sprintf(file, "/proc/bus/pci/%02x/%02x.%1x", |
116 |
if (stat("/proc/bus/pci/00", &ignored) < 0) |
116 |
bus, dev, func); |
117 |
sprintf(file, "/proc/bus/pci/%02x/%02x.%1x", |
117 |
else |
118 |
bus, dev, func); |
118 |
sprintf(file, "/proc/bus/pci/%04x/%02x.%1x", |
119 |
else |
119 |
bus, dev, func); |
120 |
sprintf(file, "/proc/bus/pci/0000:%02x/%02x.%1x", |
|
|
121 |
bus, dev, func); |
122 |
} else { |
123 |
if (stat("/proc/bus/pci/00", &ignored) < 0) |
124 |
sprintf(file, "/proc/bus/pci/%04x/%02x.%1x", |
125 |
bus, dev, func); |
126 |
else |
127 |
sprintf(file, "/proc/bus/pci/0000:%04x/%02x.%1x", |
128 |
bus, dev, func); |
129 |
} |
120 |
fd = open(file,O_RDWR); |
130 |
fd = open(file,O_RDWR); |
121 |
lbus = bus; |
131 |
lbus = bus; |
122 |
ldev = dev; |
132 |
ldev = dev; |