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.
This commit is contained in:
Ian Romanick 2007-01-17 14:04:43 -08:00
parent 0361611080
commit 88f248e671
6 changed files with 26 additions and 57 deletions

View File

@ -254,9 +254,7 @@ xf86IsEntityPrimary(int entityIndex)
switch (pEnt->busType) { switch (pEnt->busType) {
case BUS_PCI: case BUS_PCI:
return (pEnt->pciBusId.bus == primaryBus.id.pci.bus && return (pEnt->bus.id.pci == primaryBus.id.pci);
pEnt->pciBusId.device == primaryBus.id.pci.device &&
pEnt->pciBusId.func == primaryBus.id.pci.func);
case BUS_ISA: case BUS_ISA:
return TRUE; return TRUE;
case BUS_SBUS: case BUS_SBUS:
@ -1863,11 +1861,7 @@ busTypeSpecific(EntityPtr pEnt, xf86AccessPtr *acc_mem,
*acc_mem = *acc_io = *acc_mem_io = &AccessNULL; *acc_mem = *acc_io = *acc_mem_io = &AccessNULL;
break; break;
case BUS_PCI: { case BUS_PCI: {
struct pci_device * const dev = struct pci_device *const dev = pEnt->bus.id.pci;
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 );
if ((dev != NULL) && ((void *)dev->user_data != NULL)) { if ((dev != NULL) && ((void *)dev->user_data != NULL)) {
pciAccPtr const paccp = (pciAccPtr) dev->user_data; pciAccPtr const paccp = (pciAccPtr) dev->user_data;
@ -2988,10 +2982,11 @@ xf86FindPrimaryDevice()
switch (primaryBus.type) { switch (primaryBus.type) {
case BUS_PCI: case BUS_PCI:
bus = "PCI"; bus = "PCI";
snprintf(loc, sizeof(loc), " %2.2x:%2.2x:%1.1x", snprintf(loc, sizeof(loc), " %2.2x@%2.2x:%2.2x:%1.1x",
primaryBus.id.pci.bus, primaryBus.id.pci->bus,
primaryBus.id.pci.device, primaryBus.id.pci->domain,
primaryBus.id.pci.func); primaryBus.id.pci->dev,
primaryBus.id.pci->func);
break; break;
case BUS_ISA: case BUS_ISA:
bus = "ISA"; bus = "ISA";

View File

@ -91,7 +91,6 @@ typedef struct {
#define NEED_SHARED (NEED_MEM_SHARED | NEED_IO_SHARED) #define NEED_SHARED (NEED_MEM_SHARED | NEED_IO_SHARED)
#define busType bus.type #define busType bus.type
#define pciBusId bus.id.pci
#define isaBusId bus.id.isa #define isaBusId bus.id.isa
#define sbusBusId bus.id.sbus #define sbusBusId bus.id.sbus

View File

@ -1991,11 +1991,9 @@ xf86MatchPciInstances(const char *driverName, int vendorID,
if (retEntities[numFound - 1] == -1 && instances[i].screen > 0) { if (retEntities[numFound - 1] == -1 && instances[i].screen > 0) {
for (j = 0; j < xf86NumEntities; j++) { for (j = 0; j < xf86NumEntities; j++) {
EntityPtr pEnt = xf86Entities[j]; EntityPtr pEnt = xf86Entities[j];
if (pEnt->busType != BUS_PCI) if (pEnt->bus.type != BUS_PCI)
continue; continue;
if (pEnt->pciBusId.bus == PCI_MAKE_BUS( pPci->domain, pPci->bus ) && if (pEnt->bus.id.pci == pPci) {
pEnt->pciBusId.device == pPci->dev &&
pEnt->pciBusId.func == pPci->func) {
retEntities[numFound - 1] = j; retEntities[numFound - 1] = j;
xf86AddDevToEntity(j, instances[i].dev); xf86AddDevToEntity(j, instances[i].dev);
break; break;

View File

@ -329,10 +329,10 @@ probe_devices_from_device_sections(DriverPtr drvp)
#endif #endif
/* Allocate an entry in the lists to be returned */ /* Allocate an entry in the lists to be returned */
entry = xf86ClaimPciSlot( pPci, drvp, device_id, entry = xf86ClaimPciSlot(pPci, drvp, device_id,
devList[i], devList[i]->active ); devList[i], devList[i]->active);
if ( (entry == -1) && (devList[i]->screen > 0) ) { if ((entry == -1) && (devList[i]->screen > 0)) {
unsigned k; unsigned k;
for ( k = 0; k < xf86NumEntities; k++ ) { for ( k = 0; k < xf86NumEntities; k++ ) {
@ -340,19 +340,17 @@ probe_devices_from_device_sections(DriverPtr drvp)
if (pEnt->busType != BUS_PCI) if (pEnt->busType != BUS_PCI)
continue; continue;
if (pEnt->pciBusId.bus == PCI_MAKE_BUS( pPci->domain, pPci->bus ) && if (pEnt->bus.id.pci == pPci) {
pEnt->pciBusId.device == pPci->dev &&
pEnt->pciBusId.func == pPci->func) {
entry = k; entry = k;
xf86AddDevToEntity( k, devList[i] ); xf86AddDevToEntity(k, devList[i]);
break; break;
} }
} }
} }
if ( entry != -1 ) { if (entry != -1) {
if ( (*drvp->PciProbe)( drvp, entry, pPci, if ((*drvp->PciProbe)(drvp, entry, pPci,
devices[j].match_data ) ) { devices[j].match_data)) {
foundScreen = TRUE; foundScreen = TRUE;
} }
} }

View File

@ -149,9 +149,7 @@ FindPCIVideoInfo(void)
&& ((num == 1) || IS_VGA(info->device_class))) { && ((num == 1) || IS_VGA(info->device_class))) {
if (primaryBus.type == BUS_NONE) { if (primaryBus.type == BUS_NONE) {
primaryBus.type = BUS_PCI; primaryBus.type = BUS_PCI;
primaryBus.id.pci.bus = PCI_MAKE_BUS( info->domain, info->bus ); primaryBus.id.pci = info;
primaryBus.id.pci.device = info->dev;
primaryBus.id.pci.func = info->func;
} else { } else {
xf86Msg(X_NOTICE, xf86Msg(X_NOTICE,
"More than one possible primary device found\n"); "More than one possible primary device found\n");
@ -801,10 +799,8 @@ xf86ClaimPciSlot(struct pci_device * d, DriverPtr drvp,
p = xf86Entities[num]; p = xf86Entities[num];
p->driver = drvp; p->driver = drvp;
p->chipset = chipset; p->chipset = chipset;
p->busType = BUS_PCI; p->bus.type = BUS_PCI;
p->pciBusId.bus = bus; p->bus.id.pci = d;
p->pciBusId.device = d->dev;
p->pciBusId.func = d->func;
p->active = active; p->active = active;
p->inUse = FALSE; p->inUse = FALSE;
if (dev) if (dev)
@ -937,14 +933,9 @@ xf86ComparePciBusString(const char *busID, int bus, int device, int func)
*/ */
_X_EXPORT Bool _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) && (pPci == primaryBus.id.pci));
return ((primaryBus.type == BUS_PCI)
&& (busnum == primaryBus.id.pci.bus)
&& (pPci->dev == primaryBus.id.pci.device)
&& (pPci->func == primaryBus.id.pci.func));
} }
/* /*
@ -959,12 +950,7 @@ xf86GetPciInfoForEntity(int entityIndex)
return NULL; return NULL;
p = xf86Entities[entityIndex]; p = xf86Entities[entityIndex];
return (p->busType == BUS_PCI) return (p->bus.type == BUS_PCI) ? p->bus.id.pci : NULL;
? 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;
} }
/* /*
@ -994,10 +980,7 @@ xf86CheckPciSlot(const struct pci_device *d)
for (i = 0; i < xf86NumEntities; i++) { for (i = 0; i < xf86NumEntities; i++) {
const EntityPtr p = xf86Entities[i]; const EntityPtr p = xf86Entities[i];
if ((p->busType == BUS_PCI) && if ((p->bus.type == BUS_PCI) && (p->bus.id.pci == d)) {
(p->pciBusId.bus == PCI_MAKE_BUS(d->domain, d->bus)) &&
(p->pciBusId.device == d->dev) &&
(p->pciBusId.func == d->func)) {
return FALSE; return FALSE;
} }
} }

View File

@ -378,11 +378,7 @@ typedef enum {
BUS_last /* Keep last */ BUS_last /* Keep last */
} BusType; } BusType;
typedef struct { struct pci_device;
int bus;
int device;
int func;
} PciBusId;
typedef struct { typedef struct {
unsigned int dummy; unsigned int dummy;
@ -396,7 +392,7 @@ typedef struct _bus {
BusType type; BusType type;
union { union {
IsaBusId isa; IsaBusId isa;
PciBusId pci; struct pci_device *pci;
SbusBusId sbus; SbusBusId sbus;
} id; } id;
} BusRec, *BusPtr; } BusRec, *BusPtr;