From owner-freebsd-bugs@FreeBSD.ORG Tue Dec 2 07:10:28 2003 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id B26AD16A4CE for ; Tue, 2 Dec 2003 07:10:28 -0800 (PST) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 53C3743FE9 for ; Tue, 2 Dec 2003 07:10:26 -0800 (PST) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.9/8.12.9) with ESMTP id hB2FAQFY026703 for ; Tue, 2 Dec 2003 07:10:26 -0800 (PST) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.9/8.12.9/Submit) id hB2FAQT2026702; Tue, 2 Dec 2003 07:10:26 -0800 (PST) (envelope-from gnats) Resent-Date: Tue, 2 Dec 2003 07:10:26 -0800 (PST) Resent-Message-Id: <200312021510.hB2FAQT2026702@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Bruno Garagnon Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id C63CD16A4CE for ; 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 ; 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 To: FreeBSD-gnats-submit@FreeBSD.org cc: Bruno Garagnon Subject: kern/59903: "pci_find_device" returns [only/at] the first PCI VEN/DEV ID device X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Dec 2003 15:10:28 -0000 >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: