diff options
author | kib <kib@FreeBSD.org> | 2011-07-09 14:30:13 +0000 |
---|---|---|
committer | kib <kib@FreeBSD.org> | 2011-07-09 14:30:13 +0000 |
commit | 26ea307b06ce1fe08c2f4f2fe5184be760b89642 (patch) | |
tree | 89267b05a94561daab9bcfd0de5bc41be6ff206f /sys/dev/pci | |
parent | 9ff457423470dfc19b362f2221cd62a1d2807500 (diff) | |
download | FreeBSD-src-26ea307b06ce1fe08c2f4f2fe5184be760b89642.zip FreeBSD-src-26ea307b06ce1fe08c2f4f2fe5184be760b89642.tar.gz |
Implement pci_find_class(9), the function to find a pci device by its class.
Sponsored by: The FreeBSD Foundation
Reviewed by: jhb
MFC after: 1 week
Diffstat (limited to 'sys/dev/pci')
-rw-r--r-- | sys/dev/pci/pci.c | 15 | ||||
-rw-r--r-- | sys/dev/pci/pcivar.h | 1 |
2 files changed, 16 insertions, 0 deletions
diff --git a/sys/dev/pci/pci.c b/sys/dev/pci/pci.c index b346dd3..004190a 100644 --- a/sys/dev/pci/pci.c +++ b/sys/dev/pci/pci.c @@ -347,6 +347,21 @@ pci_find_device(uint16_t vendor, uint16_t device) return (NULL); } +device_t +pci_find_class(uint8_t class, uint8_t subclass) +{ + struct pci_devinfo *dinfo; + + STAILQ_FOREACH(dinfo, &pci_devq, pci_links) { + if (dinfo->cfg.baseclass == class && + dinfo->cfg.subclass == subclass) { + return (dinfo->cfg.dev); + } + } + + return (NULL); +} + static int pci_printf(pcicfgregs *cfg, const char *fmt, ...) { diff --git a/sys/dev/pci/pcivar.h b/sys/dev/pci/pcivar.h index ae3fe79..8fd84a7 100644 --- a/sys/dev/pci/pcivar.h +++ b/sys/dev/pci/pcivar.h @@ -457,6 +457,7 @@ pci_msix_count(device_t dev) device_t pci_find_bsf(uint8_t, uint8_t, uint8_t); device_t pci_find_dbsf(uint32_t, uint8_t, uint8_t, uint8_t); device_t pci_find_device(uint16_t, uint16_t); +device_t pci_find_class(uint8_t class, uint8_t subclass); /* Can be used by drivers to manage the MSI-X table. */ int pci_pending_msix(device_t dev, u_int index); |