From 9f3ad65251832631630f7e587b409b750a144bd3 Mon Sep 17 00:00:00 2001 From: Luc Verhaegen Date: Wed, 5 Oct 2005 07:27:52 +0000 Subject: [PATCH] Fix lnx_pci.c's xf86GetOSOffsetFromPCI return value. Clears up the resource ranges awkwardness and the "INVALID MEM ALLOCATION" warning. --- hw/xfree86/os-support/linux/lnx_pci.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/hw/xfree86/os-support/linux/lnx_pci.c b/hw/xfree86/os-support/linux/lnx_pci.c index 1b74fcbbd..cec9226c8 100644 --- a/hw/xfree86/os-support/linux/lnx_pci.c +++ b/hw/xfree86/os-support/linux/lnx_pci.c @@ -166,7 +166,7 @@ xf86GetOSOffsetFromPCI(PCITAG tag, int space, unsigned long base) unsigned int ndx; if (!(file = fopen("/proc/bus/pci/devices","r"))) - return NULL; + return 0; do { res = fgets(c,0x1ff,file); if (res) { @@ -194,7 +194,7 @@ xf86GetOSOffsetFromPCI(PCITAG tag, int space, unsigned long base) &size[3], &size[4], &size[5], &size[6]); if (num != 16) { /* apparantly not 2.3 style */ fclose(file); - return NULL; + return 0; } dev = devfn >> 3; @@ -213,10 +213,11 @@ xf86GetOSOffsetFromPCI(PCITAG tag, int space, unsigned long base) else /* this the ROM bar */ savePtr = (0xFFFFFFF0) & pciReadLong(tag, PCI_CMD_BASE_REG + (0x4 * ndx)); + /* find the index of the incoming base */ if (base >= savePtr && base <= (savePtr + size[ndx])) { fclose(file); - return ( ~(0xFUL) & (offset[ndx] + (base - savePtr))); + return (offset[ndx] & ~(0xFUL)) + (base - savePtr); } } } @@ -224,6 +225,6 @@ xf86GetOSOffsetFromPCI(PCITAG tag, int space, unsigned long base) } while (res); fclose(file); - return NULL; + return 0; }