summaryrefslogtreecommitdiff
path: root/xserver
diff options
context:
space:
mode:
authorMatthieu Herrb <matthieu@cvs.openbsd.org>2007-12-10 06:35:25 +0000
committerMatthieu Herrb <matthieu@cvs.openbsd.org>2007-12-10 06:35:25 +0000
commit05dcfbdd8751f9212087b6e6669e4731b8043137 (patch)
tree18ba8729bc2be0a85e02e7040a31bac3ea04efa2 /xserver
parent29e1cbf3cb0737a25b2017c5e7e0ed88853652f6 (diff)
Fix logic error in the new dynamic array of pci devices that made
xf86scanpci() exit early if pciInit() had been called already. Fix tested by krw@.
Diffstat (limited to 'xserver')
-rw-r--r--xserver/hw/xfree86/os-support/bus/Pci.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/xserver/hw/xfree86/os-support/bus/Pci.c b/xserver/hw/xfree86/os-support/bus/Pci.c
index b80371d83..2fdfa78bf 100644
--- a/xserver/hw/xfree86/os-support/bus/Pci.c
+++ b/xserver/hw/xfree86/os-support/bus/Pci.c
@@ -232,14 +232,14 @@ _X_EXPORT int pciNumBuses = 0; /* Actual number of PCI buses */
int pciMaxBusNum = MAX_PCI_BUSES;
static Bool inProbe = FALSE;
-static pciConfigPtr pci_devp[MAX_PCI_DEVICES + 1] = {NULL, };
+static pciConfigPtr *pci_devp = NULL;
static int readPciBios( PCITAG Tag, CARD8* tmp, ADDRESS hostbase,
unsigned char * buf, int len, PciBiosType BiosType );
static int (*pciOSHandleBIOS)(PCITAG Tag, int basereg, unsigned char *buf, int len);
-int xf86MaxPciDevs = MAX_PCI_DEVICES;
+int xf86MaxPciDevs = 0;
/*
* Platform specific PCI function pointers.
@@ -272,6 +272,14 @@ pciInit()
if (pciNumBuses <= 0)
ARCH_PCI_OS_INIT();
#endif
+ if (xf86MaxPciDevs == 0) {
+ xf86Msg(X_WARNING,
+ "OS did not count PCI devices, guessing wildly\n");
+ xf86MaxPciDevs = MAX_PCI_DEVICES;
+ }
+ if (pci_devp)
+ xfree(pci_devp);
+ pci_devp = xnfcalloc(xf86MaxPciDevs + 1, sizeof(pciConfigPtr));
}
void pciSetOSBIOSPtr(int (*bios_fn)(PCITAG Tag, int basereg, unsigned char * buf, int len))
@@ -920,7 +928,7 @@ xf86scanpci(int flags)
* result in an endless recursion if platform/OS specific PCI
* bus probing code calls this function from with in it.
*/
- if (done || pci_devp[0])
+ if (done || (pci_devp && pci_devp[0]))
return pci_devp;
done = TRUE;
@@ -1085,7 +1093,7 @@ xf86GetPciConfigFromTag(PCITAG Tag)
pciConfigPtr pDev;
int i = 0;
- for (i = 0 ; (pDev = pci_devp[i]) && i <= MAX_PCI_DEVICES; i++) {
+ for (i = 0 ; (pDev = pci_devp[i]) && i <= xf86MaxPciDevs; i++) {
if (Tag == pDev->tag)
return pDev;
}