Eliminate the last few places outside xf86pciBus.c that use

xf86PciVideoInfo.  In all cases this means converting the code to use
the pci_device_iterator interfaces.
This commit is contained in:
Ian Romanick 2006-08-02 13:33:33 -07:00
parent 5bfb2ee965
commit 83ebf61ec0
4 changed files with 55 additions and 56 deletions

View File

@ -213,24 +213,24 @@ xf86AutoConfig(void)
{
const char **p;
char buf[1024];
struct pci_device ** pciptr;
struct pci_device_iterator *iter;
struct pci_device * info = NULL;
char *driver = NULL;
ConfigStatus ret;
/* Find the primary device, and get some information about it. */
if (xf86PciVideoInfo) {
for (pciptr = xf86PciVideoInfo; (info = *pciptr); pciptr++) {
iter = pci_slot_match_iterator_create(NULL);
while ((info = pci_device_next(iter)) != NULL) {
if (xf86IsPrimaryPci(info)) {
break;
}
}
pci_iterator_destroy(iter);
if (!info) {
ErrorF("Primary device is not PCI\n");
}
} else {
ErrorF("xf86PciVideoInfo is not set\n");
}
if (info)
driver = videoPtrToDriverName(info);

View File

@ -1628,7 +1628,7 @@ xf86MatchPciInstances(const char *driverName, int vendorID,
{
int i,j;
struct pci_device * pPci;
struct pci_device ** ppPci;
struct pci_device_iterator *iter;
struct Inst *instances = NULL;
int numClaimedInstances = 0;
int allocatedInstances = 0;
@ -1648,20 +1648,22 @@ xf86MatchPciInstances(const char *driverName, int vendorID,
*/
if ( !xf86DoProbe && !(xf86DoConfigure && xf86DoConfigurePass1) ) {
unsigned max_entries = numDevs;
for (ppPci = xf86PciVideoInfo ; *ppPci != NULL ; ppPci++) {
iter = pci_slot_match_iterator_create(NULL);
while ((pPci = pci_device_next(iter)) != NULL) {
max_entries++;
}
pci_iterator_destroy(iter);
instances = xnfalloc(max_entries * sizeof(struct Inst));
}
for (ppPci = xf86PciVideoInfo; *ppPci != NULL; ppPci++) {
unsigned device_class = (*ppPci)->device_class;
iter = pci_slot_match_iterator_create(NULL);
while ((pPci = pci_device_next(iter)) != NULL) {
unsigned device_class = pPci->device_class;
Bool foundVendor = FALSE;
pPci = *ppPci;
/* Convert the pre-PCI 2.0 device class for a VGA adapter to the
* 2.0 version of the same class.
*/
@ -1690,7 +1692,7 @@ xf86MatchPciInstances(const char *driverName, int vendorID,
|| ((vendorID == PCI_VENDOR_GENERIC) && (match_class == device_class))) {
if (!foundVendor && (instances != NULL)) {
++allocatedInstances;
instances[allocatedInstances - 1].pci = *ppPci;
instances[allocatedInstances - 1].pci = pPci;
instances[allocatedInstances - 1].dev = NULL;
instances[allocatedInstances - 1].claimed = FALSE;
instances[allocatedInstances - 1].foundHW = FALSE;
@ -1735,6 +1737,8 @@ xf86MatchPciInstances(const char *driverName, int vendorID,
}
}
pci_iterator_destroy(iter);
/* In "probe only" or "configure" mode (signaled by instances being NULL),
* our work is done. Return the number of detected devices.

View File

@ -272,7 +272,6 @@ probe_devices_from_device_sections(DriverPtr drvp)
{
int i, j;
struct pci_device * pPci;
struct pci_device **ppPci;
Bool foundScreen = FALSE;
const struct pci_id_match * const devices = drvp->supported_devices;
GDevPtr *devList;
@ -280,15 +279,14 @@ probe_devices_from_device_sections(DriverPtr drvp)
for ( i = 0 ; i < numDevs ; i++ ) {
struct pci_device_iterator *iter;
unsigned device_id;
/* Find the pciVideoRec associated with this device section.
*/
pPci = NULL;
for (ppPci = xf86PciVideoInfo; *ppPci != NULL; ppPci++) {
pPci = *ppPci;
iter = pci_id_match_iterator_create(NULL);
while ((pPci = pci_device_next(iter)) != NULL) {
if (devList[i]->busID && *devList[i]->busID) {
if (xf86ComparePciBusString(devList[i]->busID,
((pPci->domain << 8)
@ -303,6 +301,8 @@ probe_devices_from_device_sections(DriverPtr drvp)
}
}
pci_iterator_destroy(iter);
if (pPci == NULL) {
continue;
}
@ -380,14 +380,13 @@ add_matching_devices_to_configure_list(DriverPtr drvp)
{
const struct pci_id_match * const devices = drvp->supported_devices;
int j;
struct pci_device ** ppPci;
struct pci_device *pPci;
struct pci_device_iterator *iter;
int numFound = 0;
for (ppPci = xf86PciVideoInfo; *ppPci != NULL; ppPci++) {
struct pci_device * const pPci = *ppPci;
iter = pci_id_match_iterator_create(NULL);
while ((pPci = pci_device_next(iter)) != NULL) {
/* Determine if this device is supported by the driver. If it is,
* add it to the list of devices to configure.
*/
@ -415,6 +414,8 @@ add_matching_devices_to_configure_list(DriverPtr drvp)
}
}
pci_iterator_destroy(iter);
return (numFound != 0);
}
@ -425,25 +426,20 @@ check_for_matching_devices(DriverPtr drvp)
{
const struct pci_id_match * const devices = drvp->supported_devices;
int j;
struct pci_device ** ppPci;
for (ppPci = xf86PciVideoInfo; *ppPci != NULL; ppPci++) {
const struct pci_device * pPci = *ppPci;
/* Determine if this device is supported by the driver. If it is,
* add it to the list of devices to configure.
*/
for (j = 0; ! END_OF_MATCHES(devices[j]); j++) {
if ( PCI_ID_COMPARE( devices[j].vendor_id, pPci->vendor_id )
&& PCI_ID_COMPARE( devices[j].device_id, pPci->device_id )
&& ((devices[j].device_class_mask & pPci->device_class)
== devices[j].device_class) ) {
struct pci_device_iterator *iter;
struct pci_device *dev;
iter = pci_id_match_iterator_create(& devices[j]);
dev = pci_device_next(iter);
pci_iterator_destroy(iter);
if (dev != NULL) {
return TRUE;
}
}
}
return FALSE;

View File

@ -104,7 +104,6 @@ extern Bool xf86Resetting;
extern Bool xf86Initialising;
extern Bool xf86ProbeFailed;
extern int xf86NumScreens;
extern struct pci_device ** xf86PciVideoInfo;
extern xf86CurrentAccessRec xf86CurrentAccess;
extern const char *xf86VisualNames[];
extern int xf86Verbose; /* verbosity level */