Date: Fri, 16 Jan 2026 19:40:49 +0000 From: Bjoern A. Zeeb <bz@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Subject: git: baefe812214e - stable/14 - LinuxKPI: pci: implement for_each_pci_dev() and improve pci_get_device() Message-ID: <696a9441.dcf8.f09f6d6@gitrepo.freebsd.org>
index | next in thread | raw e-mail
The branch stable/14 has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=baefe812214ebdeb042cf5a85e8232f4ee1a97ab commit baefe812214ebdeb042cf5a85e8232f4ee1a97ab Author: Bjoern A. Zeeb <bz@FreeBSD.org> AuthorDate: 2025-09-04 20:20:15 +0000 Commit: Bjoern A. Zeeb <bz@FreeBSD.org> CommitDate: 2026-01-16 19:37:46 +0000 LinuxKPI: pci: implement for_each_pci_dev() and improve pci_get_device() Implement for_each_pci_dev() needed by a wireless driver update. For that also improve pci_get_device() and add the functionality to support the odev argument to start searching from that. Sponsored by: The FreeBSD Foundation (intially) Reviewed by: dumbbell Differential Revision: https://reviews.freebsd.org/D52066 (cherry picked from commit 910cf345d0ee9a5d72856a1ba35382eb4f0db951) (cherry picked from commit 68f8fa4ada24aaf53a2d463b53259439dfb32146) --- sys/compat/linuxkpi/common/include/linux/pci.h | 3 +++ sys/compat/linuxkpi/common/src/linux_pci.c | 12 +++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/sys/compat/linuxkpi/common/include/linux/pci.h b/sys/compat/linuxkpi/common/include/linux/pci.h index 614cea0e7144..8bfb3a6a9909 100644 --- a/sys/compat/linuxkpi/common/include/linux/pci.h +++ b/sys/compat/linuxkpi/common/include/linux/pci.h @@ -1421,6 +1421,9 @@ linuxkpi_pci_get_device(uint32_t vendor, uint32_t device, struct pci_dev *odev) return (lkpi_pci_get_device(vendor, device, odev)); } +#define for_each_pci_dev(_pdev) \ + while ((_pdev = linuxkpi_pci_get_device(PCI_ANY_ID, PCI_ANY_ID, _pdev)) != NULL) + /* This is a FreeBSD extension so we can use bus_*(). */ static inline void linuxkpi_pcim_want_to_use_bus_functions(struct pci_dev *pdev) diff --git a/sys/compat/linuxkpi/common/src/linux_pci.c b/sys/compat/linuxkpi/common/src/linux_pci.c index 77acbc48c408..b2f526df0da2 100644 --- a/sys/compat/linuxkpi/common/src/linux_pci.c +++ b/sys/compat/linuxkpi/common/src/linux_pci.c @@ -290,12 +290,18 @@ lkpi_pci_get_device(uint32_t vendor, uint32_t device, struct pci_dev *odev) { struct pci_dev *pdev, *found; - KASSERT(odev == NULL, ("%s: odev argument not yet supported\n", __func__)); - found = NULL; spin_lock(&pci_lock); list_for_each_entry(pdev, &pci_devices, links) { - if (pdev->vendor == vendor && pdev->device == device) { + /* Walk until we find odev. */ + if (odev != NULL) { + if (pdev == odev) + odev = NULL; + continue; + } + + if ((pdev->vendor == vendor || vendor == PCI_ANY_ID) && + (pdev->device == device || device == PCI_ANY_ID)) { found = pdev; break; }home | help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?696a9441.dcf8.f09f6d6>
