xserver: Branch 'master'

Ian Romanick idr at kemper.freedesktop.org
Thu Jul 6 22:47:51 EEST 2006


 hw/xfree86/os-support/bus/linuxPci.c |   59 +++++++++++++----------------------
 1 files changed, 23 insertions(+), 36 deletions(-)

New commits:
diff-tree 8d07ee070ecf0d403d9d27c80764d343b80af6f0 (from 704e645207d88a2d0a372cf69f6abd778ed4c30b)
Author: Ian Romanick <idr at umwelt.(none)>
Date:   Thu Jul 6 12:48:51 2006 -0700

    Refactor linuxGetIOSize and linuxGetSizes.  Eliminate the unnecessary
    optimization in the search loop.

diff --git a/hw/xfree86/os-support/bus/linuxPci.c b/hw/xfree86/os-support/bus/linuxPci.c
index 0714c9c..7f6376a 100644
--- a/hw/xfree86/os-support/bus/linuxPci.c
+++ b/hw/xfree86/os-support/bus/linuxPci.c
@@ -421,7 +421,7 @@ xf86GetPciHostConfigFromTag(PCITAG Tag)
  *
  * Please keep this table in ascending vendor/device order.
  */
-static struct pciSizes {
+static const struct pciSizes {
     unsigned short vendor, device;
     unsigned long io_size, mem_size;
 } pciControllerSizes[] = {
@@ -444,9 +444,12 @@ static struct pciSizes {
 };
 #define NUM_SIZES (sizeof(pciControllerSizes) / sizeof(pciControllerSizes[0]))
 
-static unsigned long
-linuxGetIOSize(PCITAG Tag)
+static const struct pciSizes *
+linuxGetSizesStruct(PCITAG Tag)
 {
+    static const struct pciSizes default_size = {
+	0, 0, 1U << 16, (unsigned long)(1ULL << 32)
+    };
     pciConfigPtr pPCI;
     int          i;
 
@@ -454,47 +457,31 @@ linuxGetIOSize(PCITAG Tag)
     if ((pPCI = xf86GetPciHostConfigFromTag(Tag))) {
 	/* Look up vendor/device */
 	for (i = 0;  i < NUM_SIZES;  i++) {
-	    if (pPCI->pci_vendor > pciControllerSizes[i].vendor)
-		continue;
-	    if (pPCI->pci_vendor < pciControllerSizes[i].vendor)
-		break;
-	    if (pPCI->pci_device > pciControllerSizes[i].device)
-		continue;
-	    if (pPCI->pci_device < pciControllerSizes[i].device)
-		break;
-	    return pciControllerSizes[i].io_size;
+	    if ((pPCI->pci_vendor == pciControllerSizes[i].vendor)
+		&& (pPCI->pci_device == pciControllerSizes[i].device)) {
+		return & pciControllerSizes[i];
+	    }
 	}
     }
 
-    return 1U << 16;			/* Default to 64K */
+    /* Default to 64KB I/O and 4GB memory. */
+    return & default_size;
 }
 
-static void
-linuxGetSizes(PCITAG Tag, unsigned long *io_size, unsigned long *mem_size)
+static __inline__ unsigned long
+linuxGetIOSize(PCITAG Tag)
 {
-    pciConfigPtr pPCI;
-    int          i;
+    const struct pciSizes * const sizes = linuxGetSizesStruct(Tag);
+    return sizes->io_size;
+}
 
-    *io_size  = (1U << 16);			/* Default to 64K */
-    *mem_size = (unsigned long)(1ULL << 32);	/* Default to 4G */
+static __inline__ void
+linuxGetSizes(PCITAG Tag, unsigned long *io_size, unsigned long *mem_size)
+{
+    const struct pciSizes * const sizes = linuxGetSizesStruct(Tag);
 
-    /* Find host bridge */
-    if ((pPCI = xf86GetPciHostConfigFromTag(Tag))) {
-	/* Look up vendor/device */
-	for (i = 0;  i < NUM_SIZES;  i++) {
-	    if (pPCI->pci_vendor > pciControllerSizes[i].vendor)
-		continue;
-	    if (pPCI->pci_vendor < pciControllerSizes[i].vendor)
-		break;
-	    if (pPCI->pci_device > pciControllerSizes[i].device)
-		continue;
-	    if (pPCI->pci_device < pciControllerSizes[i].device)
-		break;
-	    *io_size  = pciControllerSizes[i].io_size;
-	    *mem_size = pciControllerSizes[i].mem_size;
-	    break;
-	}
-    }
+    *io_size  = sizes->io_size;
+    *mem_size = sizes->mem_size;
 }
 
 _X_EXPORT int



More information about the xorg-commit mailing list