git: 5b1171a0b75f - main - LinuxKPI: Add pci_match_id to linux/pci.h
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sun, 21 Jul 2024 13:14:51 UTC
The branch main has been updated by wulf: URL: https://cgit.FreeBSD.org/src/commit/?id=5b1171a0b75fc88bffb5a67b0b02d8d59eb8d5c4 commit 5b1171a0b75fc88bffb5a67b0b02d8d59eb8d5c4 Author: Vladimir Kondratyev <wulf@FreeBSD.org> AuthorDate: 2024-07-21 13:09:27 +0000 Commit: Vladimir Kondratyev <wulf@FreeBSD.org> CommitDate: 2024-07-21 13:09:27 +0000 LinuxKPI: Add pci_match_id to linux/pci.h It finds out if a given PCI device matches a given pci_id table. Sponsored by: Serenity Cyber Security, LLC MFC after: 1 week Reviewed by: manu Differential Revision: https://reviews.freebsd.org/D45846 --- sys/compat/linuxkpi/common/include/linux/pci.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/sys/compat/linuxkpi/common/include/linux/pci.h b/sys/compat/linuxkpi/common/include/linux/pci.h index be3b13f07e53..9c6a52aab83f 100644 --- a/sys/compat/linuxkpi/common/include/linux/pci.h +++ b/sys/compat/linuxkpi/common/include/linux/pci.h @@ -1268,6 +1268,29 @@ pci_dev_present(const struct pci_device_id *cur) return (0); } +static inline const struct pci_device_id * +pci_match_id(const struct pci_device_id *ids, struct pci_dev *pdev) +{ + if (ids == NULL) + return (NULL); + + for (; + ids->vendor != 0 || ids->subvendor != 0 || ids->class_mask != 0; + ids++) + if ((ids->vendor == PCI_ANY_ID || + ids->vendor == pdev->vendor) && + (ids->device == PCI_ANY_ID || + ids->device == pdev->device) && + (ids->subvendor == PCI_ANY_ID || + ids->subvendor == pdev->subsystem_vendor) && + (ids->subdevice == PCI_ANY_ID || + ids->subdevice == pdev->subsystem_device) && + ((ids->class ^ pdev->class) & ids->class_mask) == 0) + return (ids); + + return (NULL); +} + struct pci_dev *lkpi_pci_get_domain_bus_and_slot(int domain, unsigned int bus, unsigned int devfn); #define pci_get_domain_bus_and_slot(domain, bus, devfn) \