diff options
author | 2006-03-22 00:36:03 +0000 | |
---|---|---|
committer | 2006-03-22 00:36:03 +0000 | |
commit | 1389f94359ed5ddc7063a27e87cd67d772fa9701 (patch) | |
tree | 171b10a227b18c40f5be0d20b6ca8e8020633586 | |
parent | adopt to recent changes. noticed by david@ (diff) | |
download | wireguard-openbsd-1389f94359ed5ddc7063a27e87cd67d772fa9701.tar.xz wireguard-openbsd-1389f94359ed5ddc7063a27e87cd67d772fa9701.zip |
Add pci_find_device() a helper function for enumerating the
PCI bus, from NetBSD. This is useful for things like finding
another device in a driver ie ISA bridge in pciide.
ok brad@ grange@, looks ok kettenis@
-rw-r--r-- | sys/dev/pci/pci.c | 20 | ||||
-rw-r--r-- | sys/dev/pci/pcivar.h | 4 |
2 files changed, 22 insertions, 2 deletions
diff --git a/sys/dev/pci/pci.c b/sys/dev/pci/pci.c index 39ebe299281..eb28392e01e 100644 --- a/sys/dev/pci/pci.c +++ b/sys/dev/pci/pci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pci.c,v 1.44 2006/03/20 01:53:24 brad Exp $ */ +/* $OpenBSD: pci.c,v 1.45 2006/03/22 00:36:03 jsg Exp $ */ /* $NetBSD: pci.c,v 1.31 1997/06/06 23:48:04 thorpej Exp $ */ /* @@ -403,6 +403,24 @@ pci_get_capability(pci_chipset_tag_t pc, pcitag_t tag, int capid, return (0); } +int +pci_find_device(struct pci_attach_args *pa, + int (*match)(struct pci_attach_args *)) +{ + extern struct cfdriver pci_cd; + struct device *pcidev; + int i; + + for (i = 0; i < pci_cd.cd_ndevs; i++) { + pcidev = pci_cd.cd_devs[i]; + if (pcidev != NULL && + pci_enumerate_bus((struct pci_softc *)pcidev, + match, pa) != 0) + return (1); + } + return (0); +} + #ifndef PCI_MACHDEP_ENUMERATE_BUS /* * Generic PCI bus enumeration routine. Used unless machine-dependent diff --git a/sys/dev/pci/pcivar.h b/sys/dev/pci/pcivar.h index 9329ef809a6..cabf04e4946 100644 --- a/sys/dev/pci/pcivar.h +++ b/sys/dev/pci/pcivar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pcivar.h,v 1.46 2006/03/19 21:25:04 brad Exp $ */ +/* $OpenBSD: pcivar.h,v 1.47 2006/03/22 00:36:03 jsg Exp $ */ /* $NetBSD: pcivar.h,v 1.23 1997/06/06 23:48:05 thorpej Exp $ */ /* @@ -209,6 +209,8 @@ int pci_matchbyid(struct pci_attach_args *, const struct pci_matchid *, int); * Helper functions for autoconfiguration. */ const char *pci_findvendor(pcireg_t); +int pci_find_device(struct pci_attach_args *pa, + int (*match)(struct pci_attach_args *)); int pci_probe_device(struct pci_softc *, pcitag_t tag, int (*)(struct pci_attach_args *), struct pci_attach_args *); void pci_devinfo(pcireg_t, pcireg_t, int, char *, size_t); |