diff options
Diffstat (limited to 'drivers/pci')
-rw-r--r-- | drivers/pci/search.c | 39 |
1 files changed, 22 insertions, 17 deletions
diff --git a/drivers/pci/search.c b/drivers/pci/search.c index 2f13eba5d5ae..2bbafe0f79b1 100644 --- a/drivers/pci/search.c +++ b/drivers/pci/search.c | |||
@@ -413,6 +413,24 @@ exit: | |||
413 | return dev; | 413 | return dev; |
414 | } | 414 | } |
415 | 415 | ||
416 | const struct pci_device_id *pci_find_present(const struct pci_device_id *ids) | ||
417 | { | ||
418 | struct pci_dev *dev; | ||
419 | struct pci_device_id * found = NULL; | ||
420 | |||
421 | WARN_ON(in_interrupt()); | ||
422 | down_read(&pci_bus_sem); | ||
423 | while (ids->vendor || ids->subvendor || ids->class_mask) { | ||
424 | list_for_each_entry(dev, &pci_devices, global_list) { | ||
425 | if ((found = pci_match_one_device(ids, dev)) != NULL) | ||
426 | break; | ||
427 | } | ||
428 | ids++; | ||
429 | } | ||
430 | up_read(&pci_bus_sem); | ||
431 | return found; | ||
432 | } | ||
433 | |||
416 | /** | 434 | /** |
417 | * pci_dev_present - Returns 1 if device matching the device list is present, 0 if not. | 435 | * pci_dev_present - Returns 1 if device matching the device list is present, 0 if not. |
418 | * @ids: A pointer to a null terminated list of struct pci_device_id structures | 436 | * @ids: A pointer to a null terminated list of struct pci_device_id structures |
@@ -424,27 +442,14 @@ exit: | |||
424 | * find devices that are usually built into a system, or for a general hint as | 442 | * find devices that are usually built into a system, or for a general hint as |
425 | * to if another device happens to be present at this specific moment in time. | 443 | * to if another device happens to be present at this specific moment in time. |
426 | */ | 444 | */ |
445 | |||
427 | int pci_dev_present(const struct pci_device_id *ids) | 446 | int pci_dev_present(const struct pci_device_id *ids) |
428 | { | 447 | { |
429 | struct pci_dev *dev; | 448 | return pci_find_present(ids) == NULL ? 0 : 1; |
430 | int found = 0; | ||
431 | |||
432 | WARN_ON(in_interrupt()); | ||
433 | down_read(&pci_bus_sem); | ||
434 | while (ids->vendor || ids->subvendor || ids->class_mask) { | ||
435 | list_for_each_entry(dev, &pci_devices, global_list) { | ||
436 | if (pci_match_one_device(ids, dev)) { | ||
437 | found = 1; | ||
438 | goto exit; | ||
439 | } | ||
440 | } | ||
441 | ids++; | ||
442 | } | ||
443 | exit: | ||
444 | up_read(&pci_bus_sem); | ||
445 | return found; | ||
446 | } | 449 | } |
450 | |||
447 | EXPORT_SYMBOL(pci_dev_present); | 451 | EXPORT_SYMBOL(pci_dev_present); |
452 | EXPORT_SYMBOL(pci_find_present); | ||
448 | 453 | ||
449 | EXPORT_SYMBOL(pci_find_device); | 454 | EXPORT_SYMBOL(pci_find_device); |
450 | EXPORT_SYMBOL(pci_find_device_reverse); | 455 | EXPORT_SYMBOL(pci_find_device_reverse); |