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) {
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";

View File

@ -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

View File

@ -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;

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;