Date: Tue, 12 Jan 2021 11:42:57 GMT From: Emmanuel Vadot <manu@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: git: 8517a547a052 - main - pci: Add pci_find_class_from Message-ID: <202101121142.10CBgvmI095910@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch main has been updated by manu: URL: https://cgit.FreeBSD.org/src/commit/?id=8517a547a05209c7da2c895e2d7c296ec54dd068 commit 8517a547a05209c7da2c895e2d7c296ec54dd068 Author: Emmanuel Vadot <manu@FreeBSD.org> AuthorDate: 2020-12-10 17:38:41 +0000 Commit: Emmanuel Vadot <manu@FreeBSD.org> CommitDate: 2021-01-12 11:25:28 +0000 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 --- sys/dev/pci/pci.c | 22 ++++++++++++++++++++++ sys/dev/pci/pcivar.h | 1 + 2 files changed, 23 insertions(+) diff --git a/sys/dev/pci/pci.c b/sys/dev/pci/pci.c index 342e55681fb3..1ca128a48ad0 100644 --- a/sys/dev/pci/pci.c +++ b/sys/dev/pci/pci.c @@ -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, ...) { diff --git a/sys/dev/pci/pcivar.h b/sys/dev/pci/pcivar.h index 29de6dad93f0..0f04ca8f623c 100644 --- a/sys/dev/pci/pcivar.h +++ b/sys/dev/pci/pcivar.h @@ -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);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202101121142.10CBgvmI095910>