mirror of
https://github.com/opnsense/src.git
synced 2026-05-28 04:12:45 -04:00
pci: Add pci_find_class_from
pci_find_class_from help finding one or multiple device matching a class and subclass. If the from argument is not null we will first loop in the device list until we find the matching device and only then start to check if the class/subclass matches. Reviewed by: jhb Differential Revision: https://reviews.freebsd.org/D27549
This commit is contained in:
parent
8b18395487
commit
8517a547a0
2 changed files with 23 additions and 0 deletions
|
|
@ -493,6 +493,28 @@ pci_find_class(uint8_t class, uint8_t subclass)
|
|||
return (NULL);
|
||||
}
|
||||
|
||||
device_t
|
||||
pci_find_class_from(uint8_t class, uint8_t subclass, device_t from)
|
||||
{
|
||||
struct pci_devinfo *dinfo;
|
||||
bool found = false;
|
||||
|
||||
STAILQ_FOREACH(dinfo, &pci_devq, pci_links) {
|
||||
if (from != NULL && found == false) {
|
||||
if (from != dinfo->cfg.dev)
|
||||
continue;
|
||||
found = true;
|
||||
continue;
|
||||
}
|
||||
if (dinfo->cfg.baseclass == class &&
|
||||
dinfo->cfg.subclass == subclass) {
|
||||
return (dinfo->cfg.dev);
|
||||
}
|
||||
}
|
||||
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
static int
|
||||
pci_printf(pcicfgregs *cfg, const char *fmt, ...)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -666,6 +666,7 @@ 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);
|
||||
device_t pci_find_class_from(uint8_t class, uint8_t subclass, device_t devfrom);
|
||||
|
||||
/* Can be used by drivers to manage the MSI-X table. */
|
||||
int pci_pending_msix(device_t dev, u_int index);
|
||||
|
|
|
|||
Loading…
Reference in a new issue