From gara@midstream.com  Tue Dec  2 07:06:23 2003
Return-Path: <gara@midstream.com>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id C63CD16A4CE
	for <FreeBSD-gnats-submit@freebsd.org>; Tue,  2 Dec 2003 07:06:23 -0800 (PST)
Received: from mail2.gbronline.com (mail2.gbronline.com [12.145.226.11])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 90F1E43F3F
	for <FreeBSD-gnats-submit@freebsd.org>; Tue,  2 Dec 2003 07:06:22 -0800 (PST)
	(envelope-from bruno@midstream.com)
Received: from midstream.com [69.9.73.16] by mail2.gbronline.com with ESMTP
  (SMTPD32-8.04) id AF317BA0284; Mon, 01 Dec 2003 22:04:01 -0600
Message-Id: <3FCC0EF2.5080101@midstream.com>
Date: Mon, 01 Dec 2003 20:02:58 -0800
From: Bruno Garagnon <gara@midstream.com>
To: FreeBSD-gnats-submit@freebsd.org
Cc: Bruno Garagnon <gara@midstream.com>
Subject: "pci_find_device" returns [only/at] the first PCI VEN/DEV ID device

>Number:         59903
>Category:       kern
>Synopsis:       [pci] [patch] "pci_find_device" returns [only/at] the first PCI VEN/DEV ID device
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Tue Dec 02 07:10:25 PST 2003
>Closed-Date:    Wed Apr 27 21:27:35 UTC 2011
>Last-Modified:  Wed Apr 27 21:27:35 UTC 2011
>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:

From: Bruno Garagnon <gara@midstream.com>
To: FreeBSD-gnats-submit@freebsd.org
Cc: freebsd-bugs@FreeBSD.org
Subject: RE: kern/59903
Date: Thu, 11 Dec 2003 23:25:26 -0800

 Please remove asap the page:
 
 http://www.freebsd.org/cgi/query-pr.cgi?pr=kern/59903
 
 I've been flooded by spam almost immediately after I sent this pr...
 
 Thank you.
 
 
 
State-Changed-From-To: open->closed 
State-Changed-By: jhb 
State-Changed-When: Wed Apr 27 21:26:58 UTC 2011 
State-Changed-Why:  
Closed at submitter's request.  Also, I don't think we will add something 
like this unless someone has a compelling use case. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=59903 
>Unformatted:
