kern/59903: "pci_find_device" returns [only/at] the first PCI
VEN/DEV ID device
Bruno Garagnon
bruno at midstream.com
Tue Dec 2 07:10:28 PST 2003
>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 at 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:
More information about the freebsd-bugs
mailing list