From 00062572d3464571b4a7e7aafdf7eb2284059fe1 Mon Sep 17 00:00:00 2001 From: "H. Peter Anvin" Date: Tue, 14 Apr 2009 13:45:33 -0700 Subject: [PATCH] pci: add pci_for_each_func3() which produces an address Add pci_for_each_func3() iterator, which produces an address in addition to the device pointer. Signed-off-by: H. Peter Anvin --- com32/include/sys/pci.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/com32/include/sys/pci.h b/com32/include/sys/pci.h index 2e1871e..b44db62 100644 --- a/com32/include/sys/pci.h +++ b/com32/include/sys/pci.h @@ -80,6 +80,16 @@ struct pci_domain { if (((funcp) = (domain)->bus[__pci_bus]->slot[__pci_slot]-> \ func[__pci_func])) +#define for_each_pci_func3(funcp, domain, addr) \ + for (int __pci_bus = 0; __pci_bus < MAX_PCI_BUSES; __pci_bus++) \ + if ((domain)->bus[__pci_bus]) \ + for (int __pci_slot = 0; __pci_slot < MAX_PCI_DEVICES; __pci_slot++) \ + if ((domain)->bus[__pci_bus]->slot[__pci_slot]) \ + for (int __pci_func = 0; __pci_func < MAX_PCI_FUNC; __pci_func++) \ + if (((addr) = pci_mkaddr(__pci_bus, __pci_slot, __pci_func, 0)), \ + ((funcp) = (domain)->bus[__pci_bus]->slot[__pci_slot]-> \ + func[__pci_func])) + struct match { struct match *next; uint32_t did; -- 2.7.4