summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Romanick <idr@us.ibm.com>2007-01-17 14:04:43 -0800
committerIan Romanick <idr@us.ibm.com>2007-01-17 14:04:43 -0800
commit88f248e67143175532cbafd6faf8fc6df97c7894 (patch)
treed382e9469006a809cebd7b2fa6618bfdacd61d7f
parent0361611080267727f570e17f2212aaa890223f6e (diff)
Replace PciBusId with 'struct pci_device *'
There's no need to store the slot information for a PCI device as its ID. Instead, skip the middle man and just store a pointer to the pci_device structure.
-rw-r--r--hw/xfree86/common/xf86Bus.c19
-rw-r--r--hw/xfree86/common/xf86Bus.h1
-rw-r--r--hw/xfree86/common/xf86Helper.c6
-rw-r--r--hw/xfree86/common/xf86Init.c18
-rw-r--r--hw/xfree86/common/xf86pciBus.c31
-rw-r--r--hw/xfree86/common/xf86str.h8
6 files changed, 26 insertions, 57 deletions
diff --git a/hw/xfree86/common/xf86Bus.c b/hw/xfree86/common/xf86Bus.c
index 573c924a2..86ad0182d 100644
--- a/hw/xfree86/common/xf86Bus.c
+++ b/hw/xfree86/common/xf86Bus.c
@@ -254,9 +254,7 @@ xf86IsEntityPrimary(int entityIndex)
switch (pEnt->busType) {
case BUS_PCI:
- return (pEnt->pciBusId.bus == primaryBus.id.pci.bus &&
- pEnt->pciBusId.device == primaryBus.id.pci.device &&
- pEnt->pciBusId.func == primaryBus.id.pci.func);
+ return (pEnt->bus.id.pci == primaryBus.id.pci);
case BUS_ISA:
return TRUE;
case BUS_SBUS:
@@ -1863,11 +1861,7 @@ busTypeSpecific(EntityPtr pEnt, xf86AccessPtr *acc_mem,
*acc_mem = *acc_io = *acc_mem_io = &AccessNULL;
break;
case BUS_PCI: {
- struct pci_device * const dev =
- pci_device_find_by_slot( PCI_DOM_FROM_BUS( pEnt->pciBusId.bus ),
- PCI_BUS_NO_DOMAIN( pEnt->pciBusId.bus ),
- pEnt->pciBusId.device,
- pEnt->pciBusId.func );
+ struct pci_device *const dev = pEnt->bus.id.pci;
if ((dev != NULL) && ((void *)dev->user_data != NULL)) {
pciAccPtr const paccp = (pciAccPtr) dev->user_data;
@@ -2988,10 +2982,11 @@ xf86FindPrimaryDevice()
switch (primaryBus.type) {
case BUS_PCI:
bus = "PCI";
- snprintf(loc, sizeof(loc), " %2.2x:%2.2x:%1.1x",
- primaryBus.id.pci.bus,
- primaryBus.id.pci.device,
- primaryBus.id.pci.func);
+ 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);
break;
case BUS_ISA:
bus = "ISA";
diff --git a/hw/xfree86/common/xf86Bus.h b/hw/xfree86/common/xf86Bus.h
index 8e65023b4..f1fc627b9 100644
--- a/hw/xfree86/common/xf86Bus.h
+++ b/hw/xfree86/common/xf86Bus.h
@@ -91,7 +91,6 @@ typedef struct {
#define NEED_SHARED (NEED_MEM_SHARED | NEED_IO_SHARED)
#define busType bus.type
-#define pciBusId bus.id.pci
#define isaBusId bus.id.isa
#define sbusBusId bus.id.sbus
diff --git a/hw/xfree86/common/xf86Helper.c b/hw/xfree86/common/xf86Helper.c
index bad051302..27a90c9a7 100644
--- a/hw/xfree86/common/xf86Helper.c
+++ b/hw/xfree86/common/xf86Helper.c
@@ -1991,11 +1991,9 @@ xf86MatchPciInstances(const char *driverName, int vendorID,
if (retEntities[numFound - 1] == -1 && instances[i].screen > 0) {
for (j = 0; j < xf86NumEntities; j++) {
EntityPtr pEnt = xf86Entities[j];
- if (pEnt->busType != BUS_PCI)
+ if (pEnt->bus.type != BUS_PCI)
continue;
- if (pEnt->pciBusId.bus == PCI_MAKE_BUS( pPci->domain, pPci->bus ) &&
- pEnt->pciBusId.device == pPci->dev &&
- pEnt->pciBusId.func == pPci->func) {
+ if (pEnt->bus.id.pci == pPci) {
retEntities[numFound - 1] = j;
xf86AddDevToEntity(j, instances[i].dev);
break;
diff --git a/hw/xfree86/common/xf86Init.c b/hw/xfree86/common/xf86Init.c
index 3fc976648..f824f6867 100644
--- a/hw/xfree86/common/xf86Init.c
+++ b/hw/xfree86/common/xf86Init.c
@@ -329,10 +329,10 @@ probe_devices_from_device_sections(DriverPtr drvp)
#endif
/* Allocate an entry in the lists to be returned */
- entry = xf86ClaimPciSlot( pPci, drvp, device_id,
- devList[i], devList[i]->active );
+ entry = xf86ClaimPciSlot(pPci, drvp, device_id,
+ devList[i], devList[i]->active);
- if ( (entry == -1) && (devList[i]->screen > 0) ) {
+ if ((entry == -1) && (devList[i]->screen > 0)) {
unsigned k;
for ( k = 0; k < xf86NumEntities; k++ ) {
@@ -340,19 +340,17 @@ probe_devices_from_device_sections(DriverPtr drvp)
if (pEnt->busType != BUS_PCI)
continue;
- if (pEnt->pciBusId.bus == PCI_MAKE_BUS( pPci->domain, pPci->bus ) &&
- pEnt->pciBusId.device == pPci->dev &&
- pEnt->pciBusId.func == pPci->func) {
+ if (pEnt->bus.id.pci == pPci) {
entry = k;
- xf86AddDevToEntity( k, devList[i] );
+ xf86AddDevToEntity(k, devList[i]);
break;
}
}
}
- if ( entry != -1 ) {
- if ( (*drvp->PciProbe)( drvp, entry, pPci,
- devices[j].match_data ) ) {
+ if (entry != -1) {
+ if ((*drvp->PciProbe)(drvp, entry, pPci,
+ devices[j].match_data)) {
foundScreen = TRUE;
}
}
diff --git a/hw/xfree86/common/xf86pciBus.c b/hw/xfree86/common/xf86pciBus.c
index 5dc96b999..953be48c9 100644
--- a/hw/xfree86/common/xf86pciBus.c
+++ b/hw/xfree86/common/xf86pciBus.c
@@ -149,9 +149,7 @@ FindPCIVideoInfo(void)
&& ((num == 1) || IS_VGA(info->device_class))) {
if (primaryBus.type == BUS_NONE) {
primaryBus.type = BUS_PCI;
- primaryBus.id.pci.bus = PCI_MAKE_BUS( info->domain, info->bus );
- primaryBus.id.pci.device = info->dev;
- primaryBus.id.pci.func = info->func;
+ primaryBus.id.pci = info;
} else {
xf86Msg(X_NOTICE,
"More than one possible primary device found\n");
@@ -801,10 +799,8 @@ xf86ClaimPciSlot(struct pci_device * d, DriverPtr drvp,
p = xf86Entities[num];
p->driver = drvp;
p->chipset = chipset;
- p->busType = BUS_PCI;
- p->pciBusId.bus = bus;
- p->pciBusId.device = d->dev;
- p->pciBusId.func = d->func;
+ p->bus.type = BUS_PCI;
+ p->bus.id.pci = d;
p->active = active;
p->inUse = FALSE;
if (dev)
@@ -937,14 +933,9 @@ xf86ComparePciBusString(const char *busID, int bus, int device, int func)
*/
_X_EXPORT Bool
-xf86IsPrimaryPci( struct pci_device * pPci )
+xf86IsPrimaryPci(struct pci_device *pPci)
{
- const unsigned busnum = PCI_MAKE_BUS( pPci->domain, pPci->bus );
-
- return ((primaryBus.type == BUS_PCI)
- && (busnum == primaryBus.id.pci.bus)
- && (pPci->dev == primaryBus.id.pci.device)
- && (pPci->func == primaryBus.id.pci.func));
+ return ((primaryBus.type == BUS_PCI) && (pPci == primaryBus.id.pci));
}
/*
@@ -959,12 +950,7 @@ xf86GetPciInfoForEntity(int entityIndex)
return NULL;
p = xf86Entities[entityIndex];
- return (p->busType == BUS_PCI)
- ? pci_device_find_by_slot(PCI_DOM_FROM_BUS(p->pciBusId.bus),
- PCI_BUS_NO_DOMAIN(p->pciBusId.bus),
- p->pciBusId.device,
- p->pciBusId.func)
- : NULL;
+ return (p->bus.type == BUS_PCI) ? p->bus.id.pci : NULL;
}
/*
@@ -994,10 +980,7 @@ xf86CheckPciSlot(const struct pci_device *d)
for (i = 0; i < xf86NumEntities; i++) {
const EntityPtr p = xf86Entities[i];
- if ((p->busType == BUS_PCI) &&
- (p->pciBusId.bus == PCI_MAKE_BUS(d->domain, d->bus)) &&
- (p->pciBusId.device == d->dev) &&
- (p->pciBusId.func == d->func)) {
+ if ((p->bus.type == BUS_PCI) && (p->bus.id.pci == d)) {
return FALSE;
}
}
diff --git a/hw/xfree86/common/xf86str.h b/hw/xfree86/common/xf86str.h
index 55f439fe4..7fb884232 100644
--- a/hw/xfree86/common/xf86str.h
+++ b/hw/xfree86/common/xf86str.h
@@ -378,11 +378,7 @@ typedef enum {
BUS_last /* Keep last */
} BusType;
-typedef struct {
- int bus;
- int device;
- int func;
-} PciBusId;
+struct pci_device;
typedef struct {
unsigned int dummy;
@@ -396,7 +392,7 @@ typedef struct _bus {
BusType type;
union {
IsaBusId isa;
- PciBusId pci;
+ struct pci_device *pci;
SbusBusId sbus;
} id;
} BusRec, *BusPtr;