[PATCH 04/11] xfree86: bus: remove superfluous and confused structures in BusRec

Tiago Vignatti tiago.vignatti at nokia.com
Fri May 21 04:43:17 PDT 2010


Although API is break, luckily any drivers right now is using such monster.

Signed-off-by: Tiago Vignatti <tiago.vignatti at nokia.com>
---
 hw/xfree86/common/xf86Bus.c        |   16 ++++++++--------
 hw/xfree86/common/xf86Helper.c     |    2 +-
 hw/xfree86/common/xf86VGAarbiter.c |    2 +-
 hw/xfree86/common/xf86pciBus.c     |   16 ++++++++--------
 hw/xfree86/common/xf86sbusBus.c    |    8 ++++----
 hw/xfree86/common/xf86str.h        |   10 ++--------
 6 files changed, 24 insertions(+), 30 deletions(-)

diff --git a/hw/xfree86/common/xf86Bus.c b/hw/xfree86/common/xf86Bus.c
index 69fbdff..943574a 100644
--- a/hw/xfree86/common/xf86Bus.c
+++ b/hw/xfree86/common/xf86Bus.c
@@ -54,7 +54,7 @@ EntityPtr *xf86Entities = NULL;	/* Bus slots claimed by drivers */
 int xf86NumEntities = 0;
 static int xf86EntityPrivateCount = 0;
 
-BusRec primaryBus = { BUS_NONE, { 0 } };
+BusRec primaryBus = {BUS_NONE, 0, 0};
 
 /**
  * Call the driver's correct probe function.
@@ -261,9 +261,9 @@ xf86IsEntityPrimary(int entityIndex)
 
     switch (pEnt->bus.type) {
     case BUS_PCI:
-	return (pEnt->bus.id.pci == primaryBus.id.pci);
+	return (pEnt->bus.pci == primaryBus.pci);
     case BUS_SBUS:
-	return (pEnt->bus.id.sbus.fbNum == primaryBus.id.sbus.fbNum);
+	return (pEnt->bus.sbus == primaryBus.sbus);
     default:
 	return FALSE;
     }
@@ -572,14 +572,14 @@ xf86FindPrimaryDevice(void)
 	case BUS_PCI:
 	    bus = "PCI";
 	    snprintf(loc, sizeof(loc), " %2.2x@%2.2x:%2.2x:%1.1x",
-		     primaryBus.id.pci->bus,
-		     primaryBus.id.pci->domain,
-		     primaryBus.id.pci->dev,
-		     primaryBus.id.pci->func);
+		     primaryBus.pci->bus,
+		     primaryBus.pci->domain,
+		     primaryBus.pci->dev,
+		     primaryBus.pci->func);
 	    break;
 	case BUS_SBUS:
 	    bus = "SBUS";
-	    snprintf(loc, sizeof(loc), " %2.2x", primaryBus.id.sbus.fbNum);
+	    snprintf(loc, sizeof(loc), " %2.2x", primaryBus.sbus);
 	    break;
 	default:
 	    bus = "";
diff --git a/hw/xfree86/common/xf86Helper.c b/hw/xfree86/common/xf86Helper.c
index 9ec5941..8fa2a01 100644
--- a/hw/xfree86/common/xf86Helper.c
+++ b/hw/xfree86/common/xf86Helper.c
@@ -1904,7 +1904,7 @@ xf86MatchPciInstances(const char *driverName, int vendorID,
 	        EntityPtr pEnt = xf86Entities[j];
 	        if (pEnt->bus.type != BUS_PCI)
 		    continue;
-	        if (pEnt->bus.id.pci == pPci) {
+	        if (pEnt->bus.pci == pPci) {
 		    retEntities[numFound - 1] = j;
 		    xf86AddDevToEntity(j, instances[i].dev);
 		    break;
diff --git a/hw/xfree86/common/xf86VGAarbiter.c b/hw/xfree86/common/xf86VGAarbiter.c
index 4a736fc..7d1fcc8 100644
--- a/hw/xfree86/common/xf86VGAarbiter.c
+++ b/hw/xfree86/common/xf86VGAarbiter.c
@@ -133,7 +133,7 @@ xf86VGAarbiterScrnInit(ScrnInfoPtr pScrn)
     if (pEnt->bus.type != BUS_PCI)
 	return;
 
-    dev = pEnt->bus.id.pci;
+    dev = pEnt->bus.pci;
     pScrn->vgaDev = dev;
 }
 
diff --git a/hw/xfree86/common/xf86pciBus.c b/hw/xfree86/common/xf86pciBus.c
index 4656f1a..5e727ad 100644
--- a/hw/xfree86/common/xf86pciBus.c
+++ b/hw/xfree86/common/xf86pciBus.c
@@ -118,7 +118,7 @@ xf86PciProbe(void)
 #ifdef HAVE_PCI_DEVICE_IS_BOOT_VGA
 	    if (pci_device_is_boot_vga(info)) {
                 primaryBus.type = BUS_PCI;
-                primaryBus.id.pci = info;
+                primaryBus.pci = info;
             }
 #endif
 	    info->user_data = 0;
@@ -138,7 +138,7 @@ xf86PciProbe(void)
 		&& ((num == 1) || IS_VGA(info->device_class))) {
 		if (primaryBus.type == BUS_NONE) {
 		    primaryBus.type = BUS_PCI;
-		    primaryBus.id.pci = info;
+		    primaryBus.pci = info;
 		} else {
 		    xf86Msg(X_NOTICE,
 			    "More than one possible primary device found\n");
@@ -233,7 +233,7 @@ xf86ClaimPciSlot(struct pci_device * d, DriverPtr drvp,
 	p->driver = drvp;
 	p->chipset = chipset;
 	p->bus.type = BUS_PCI;
-	p->bus.id.pci = d;
+	p->bus.pci = d;
 	p->active = active;
 	p->inUse = FALSE;
 	if (dev)
@@ -261,7 +261,7 @@ xf86UnclaimPciSlot(struct pci_device *d)
     for (i = 0; i < xf86NumEntities; i++) {
 	const EntityPtr p = xf86Entities[i];
 
-	if ((p->bus.type == BUS_PCI) && (p->bus.id.pci == d)) {
+	if ((p->bus.type == BUS_PCI) && (p->bus.pci == d)) {
 	    /* Probably the slot should be deallocated? */
 	    p->bus.type = BUS_NONE;
 	    return;
@@ -368,7 +368,7 @@ xf86ComparePciBusString(const char *busID, int bus, int device, int func)
 Bool
 xf86IsPrimaryPci(struct pci_device *pPci)
 {
-    return ((primaryBus.type == BUS_PCI) && (pPci == primaryBus.id.pci));
+    return ((primaryBus.type == BUS_PCI) && (pPci == primaryBus.pci));
 }
 
 /*
@@ -383,7 +383,7 @@ xf86GetPciInfoForEntity(int entityIndex)
 	return NULL;
 
     p = xf86Entities[entityIndex];
-    return (p->bus.type == BUS_PCI) ? p->bus.id.pci : NULL;
+    return (p->bus.type == BUS_PCI) ? p->bus.pci : NULL;
 }
 
 /*
@@ -413,7 +413,7 @@ xf86CheckPciSlot(const struct pci_device *d)
     for (i = 0; i < xf86NumEntities; i++) {
 	const EntityPtr p = xf86Entities[i];
 
-	if ((p->bus.type == BUS_PCI) && (p->bus.id.pci == d)) {
+	if ((p->bus.type == BUS_PCI) && (p->bus.pci == d)) {
 	    return FALSE;
 	}
     }
@@ -543,7 +543,7 @@ xf86PciProbeDev(DriverPtr drvp)
                        EntityPtr pEnt = xf86Entities[k];
                        if (pEnt->bus.type != BUS_PCI)
                            continue;
-                       if (pEnt->bus.id.pci == pPci) {
+                       if (pEnt->bus.pci == pPci) {
                            entry = k;
                            xf86AddDevToEntity(k, devList[i]);
                            break;
diff --git a/hw/xfree86/common/xf86sbusBus.c b/hw/xfree86/common/xf86sbusBus.c
index ea8c3e1..2ac1361 100644
--- a/hw/xfree86/common/xf86sbusBus.c
+++ b/hw/xfree86/common/xf86sbusBus.c
@@ -319,7 +319,7 @@ xf86CheckSbusSlot(int fbNum)
     for (i = 0; i < xf86NumEntities; i++) {
 	p = xf86Entities[i];
 	/* Check if this SBUS slot is taken */
-	if (p->bus.type == BUS_SBUS && p->bus.id.sbus.fbNum == fbNum)
+	if (p->bus.type == BUS_SBUS && p->bus.sbus == fbNum)
 	    return FALSE;
     }
 
@@ -346,7 +346,7 @@ xf86ClaimSbusSlot(sbusDevicePtr psdp, DriverPtr drvp,
         p->chipset = -1;
         p->bus.type = BUS_SBUS;
         xf86AddDevToEntity(num, dev);
-        p->bus.id.sbus.fbNum = psdp->fbNum;
+        p->bus.sbus = psdp->fbNum;
         p->active = active;
         p->inUse = FALSE;
 	sbusSlotClaimed = TRUE;
@@ -530,7 +530,7 @@ xf86GetSbusInfoForEntity(int entityIndex)
 	|| p->bus.type != BUS_SBUS) return NULL;
 
     for (psdpp = xf86SbusInfo; *psdpp != NULL; psdpp++) {
-	if (p->bus.id.sbus.fbNum == (*psdpp)->fbNum)
+	if (p->bus.sbus == (*psdpp)->fbNum)
 	    return (*psdpp);
     }
     return NULL;
@@ -545,7 +545,7 @@ xf86GetEntityForSbusInfo(sbusDevicePtr psdp)
 	EntityPtr p = xf86Entities[i];
 	if (p->bus.type != BUS_SBUS) continue;
 
-	if (p->bus.id.sbus.fbNum == psdp->fbNum)
+	if (p->bus.sbus == psdp->fbNum)
 	    return i;
     }
     return -1;
diff --git a/hw/xfree86/common/xf86str.h b/hw/xfree86/common/xf86str.h
index 485c15a..e5713db 100644
--- a/hw/xfree86/common/xf86str.h
+++ b/hw/xfree86/common/xf86str.h
@@ -355,16 +355,10 @@ typedef enum {
 
 struct pci_device;
 
-typedef struct {
-    int		fbNum;
-} SbusBusId;
-
 typedef struct _bus {
     BusType type;
-    union {
-	struct pci_device *pci;
-	SbusBusId sbus;
-    } id;
+    struct pci_device *pci;
+    int sbus;
 } BusRec, *BusPtr;
 
 #define MAXCLOCKS   128
-- 
1.6.0.4



More information about the xorg-devel mailing list