Date: Mon, 01 Dec 2003 20:02:58 -0800 From: Bruno Garagnon <bruno@midstream.com> To: FreeBSD-gnats-submit@FreeBSD.org Cc: Bruno Garagnon <bruno@midstream.com> Subject: kern/59903: "pci_find_device" returns [only/at] the first PCI VEN/DEV ID device Message-ID: <3FCC0EF2.5080101@midstream.com> Resent-Message-ID: <200312021510.hB2FAQT2026702@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 59903 >Category: kern >Synopsis: "pci_find_device" returns [only/at] the first PCI VEN/DEV ID device >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Tue Dec 02 07:10:25 PST 2003 >Closed-Date: >Last-Modified: >Originator: Bruno Garagnon >Release: FreeBSD 5.1-RELEASE i386 >Organization: Midstream Technologies, Inc. >Environment: System: FreeBSD tamino.midstream.com 5.1-RELEASE FreeBSD 5.1-RELEASE #0: Thu Jun 5 02:55:42 GMT 2003 root@wv1u.btc.adaptec.com:/usr/obj/usr/src/sys/GENERIC i386 >Description: "pci_find_device" returns [only/at] the first PCI VEN/DEV ID device; need an other routine, with a call back for *all* VEN/DEV ID devices >How-To-Repeat: >Fix: *** /usr/src/sys/dev/pci/pci.c Tue Apr 15 20:15:08 2003 *** 195,212 **** --- 195,228 ---- /* Find a device_t by vendor/device ID */ device_t pci_find_device(u_int16_t vendor, u_int16_t device) { struct pci_devinfo *dinfo; STAILQ_FOREACH(dinfo, &pci_devq, pci_links) { if ((dinfo->cfg.vendor == vendor) && (dinfo->cfg.device == device)) { return (dinfo->cfg.dev); } } return (NULL); } + /* Find all device_t's by vendor/device ID, and call back caller's routine with (dev, arg) */ + + int + pci_find_devices(u_int16_t vendor, u_int16_t device, int (*callback) (device_t, void *), void *arg) + { + struct pci_devinfo *dinfo; int count = 0; + + STAILQ_FOREACH(dinfo, &pci_devq, pci_links) { + if ((dinfo->cfg.vendor == vendor) && + (dinfo->cfg.device == device)) { + count += callback (dinfo->cfg.dev, arg); + } + } + + return count; + } *** /usr/src/sys/dev/pci/pcivar.h Tue Apr 15 20:15:08 2003 *** 310,310 **** --- 310,311 ---- device_t pci_find_device(u_int16_t, u_int16_t); + int pci_find_devices(u_int16_t vendor, u_int16_t device, int (*callback) (device_t, void *), void *arg); end-of-mail >Release-Note: >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3FCC0EF2.5080101>