lib/pci: generalize pci_cap_walk

Increase the utility of pci_cap_walk by allowing the caller to supply
the table of cap handlers via a single handler, which implements all
the cases of interest.

Signed-off-by: Andrew Jones <drjones@redhat.com>
Reviewed-by: Peter Xu <peterx@redhat.com>
Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
diff --git a/lib/pci.h b/lib/pci.h
index 0815754..703c1fb 100644
--- a/lib/pci.h
+++ b/lib/pci.h
@@ -30,7 +30,8 @@
 extern void pci_dev_init(struct pci_dev *dev, pcidevaddr_t bdf);
 extern void pci_scan_bars(struct pci_dev *dev);
 extern void pci_cmd_set_clr(struct pci_dev *dev, uint16_t set, uint16_t clr);
-extern void pci_cap_walk(struct pci_dev *dev);
+typedef void (*pci_cap_handler_t)(struct pci_dev *dev, int cap_offset, int cap_id);
+extern void pci_cap_walk(struct pci_dev *dev, pci_cap_handler_t handler);
 extern void pci_enable_defaults(struct pci_dev *dev);
 extern bool pci_setup_msi(struct pci_dev *dev, uint64_t msi_addr,
 			  uint32_t msi_data);