aboutsummaryrefslogtreecommitdiffstats
path: root/internal.c
diff options
context:
space:
mode:
Diffstat (limited to 'internal.c')
-rw-r--r--internal.c37
1 files changed, 14 insertions, 23 deletions
diff --git a/internal.c b/internal.c
index 995290e7..dcb83cdb 100644
--- a/internal.c
+++ b/internal.c
@@ -36,58 +36,49 @@ enum chipbustype internal_buses_supported = BUS_NONE;
struct pci_dev *pci_dev_find_vendorclass(uint16_t vendor, uint16_t devclass)
{
- struct pci_dev *temp;
+ struct pci_dev *temp = NULL;
struct pci_filter filter;
uint16_t tmp2;
pci_filter_init(NULL, &filter);
filter.vendor = vendor;
- for (temp = pacc->devices; temp; temp = temp->next)
- if (pci_filter_match(&filter, temp)) {
- /* Read PCI class */
- tmp2 = pci_read_word(temp, 0x0a);
- if (tmp2 == devclass)
- return temp;
- }
+ while ((temp = pcidev_scandev(&filter, temp))) {
+ /* Read PCI class */
+ tmp2 = pci_read_word(temp, 0x0a);
+ if (tmp2 == devclass)
+ return temp;
+ }
return NULL;
}
struct pci_dev *pci_dev_find(uint16_t vendor, uint16_t device)
{
- struct pci_dev *temp;
struct pci_filter filter;
pci_filter_init(NULL, &filter);
filter.vendor = vendor;
filter.device = device;
- for (temp = pacc->devices; temp; temp = temp->next)
- if (pci_filter_match(&filter, temp))
- return temp;
-
- return NULL;
+ return pcidev_scandev(&filter, NULL);
}
struct pci_dev *pci_card_find(uint16_t vendor, uint16_t device,
uint16_t card_vendor, uint16_t card_device)
{
- struct pci_dev *temp;
+ struct pci_dev *temp = NULL;
struct pci_filter filter;
pci_filter_init(NULL, &filter);
filter.vendor = vendor;
filter.device = device;
- for (temp = pacc->devices; temp; temp = temp->next)
- if (pci_filter_match(&filter, temp)) {
- if ((card_vendor ==
- pci_read_word(temp, PCI_SUBSYSTEM_VENDOR_ID))
- && (card_device ==
- pci_read_word(temp, PCI_SUBSYSTEM_ID)))
- return temp;
- }
+ while ((temp = pcidev_scandev(&filter, temp))) {
+ if ((card_vendor == pci_read_word(temp, PCI_SUBSYSTEM_VENDOR_ID))
+ && (card_device == pci_read_word(temp, PCI_SUBSYSTEM_ID)))
+ return temp;
+ }
return NULL;
}