diff options
author | Jonathan Gray <jsg@cvs.openbsd.org> | 2006-03-22 00:36:04 +0000 |
---|---|---|
committer | Jonathan Gray <jsg@cvs.openbsd.org> | 2006-03-22 00:36:04 +0000 |
commit | c41c1eb74663f6c14a99ce348b1ac201e18cb5f9 (patch) | |
tree | 27aa382f3d7fecbd08fa6fcb1a4e21efab00bd8a /sys/dev | |
parent | b437ff9065d47b830fbbf9f5835cd1579d0fde3c (diff) |
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@
Diffstat (limited to 'sys/dev')
-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); |