diff options
-rw-r--r-- | drivers/pci/search.c | 39 | ||||
-rw-r--r-- | include/linux/pci.h | 2 |
2 files changed, 24 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); |
diff --git a/include/linux/pci.h b/include/linux/pci.h index 01c707261f9c..769e132b78d3 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h | |||
@@ -468,6 +468,7 @@ struct pci_dev *pci_get_slot (struct pci_bus *bus, unsigned int devfn); | |||
468 | struct pci_dev *pci_get_bus_and_slot (unsigned int bus, unsigned int devfn); | 468 | struct pci_dev *pci_get_bus_and_slot (unsigned int bus, unsigned int devfn); |
469 | struct pci_dev *pci_get_class (unsigned int class, struct pci_dev *from); | 469 | struct pci_dev *pci_get_class (unsigned int class, struct pci_dev *from); |
470 | int pci_dev_present(const struct pci_device_id *ids); | 470 | int pci_dev_present(const struct pci_device_id *ids); |
471 | const struct pci_device_id *pci_find_present(const struct pci_device_id *ids); | ||
471 | 472 | ||
472 | int pci_bus_read_config_byte (struct pci_bus *bus, unsigned int devfn, int where, u8 *val); | 473 | int pci_bus_read_config_byte (struct pci_bus *bus, unsigned int devfn, int where, u8 *val); |
473 | int pci_bus_read_config_word (struct pci_bus *bus, unsigned int devfn, int where, u16 *val); | 474 | int pci_bus_read_config_word (struct pci_bus *bus, unsigned int devfn, int where, u16 *val); |
@@ -681,6 +682,7 @@ static inline struct pci_dev *pci_get_class(unsigned int class, struct pci_dev * | |||
681 | { return NULL; } | 682 | { return NULL; } |
682 | 683 | ||
683 | #define pci_dev_present(ids) (0) | 684 | #define pci_dev_present(ids) (0) |
685 | #define pci_find_present(ids) (NULL) | ||
684 | #define pci_dev_put(dev) do { } while (0) | 686 | #define pci_dev_put(dev) do { } while (0) |
685 | 687 | ||
686 | static inline void pci_set_master(struct pci_dev *dev) { } | 688 | static inline void pci_set_master(struct pci_dev *dev) { } |