From owner-svn-src-head@FreeBSD.ORG Sat Jul 9 14:30:13 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 818C7106564A; Sat, 9 Jul 2011 14:30:13 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 720FC8FC1F; Sat, 9 Jul 2011 14:30:13 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p69EUDih003978; Sat, 9 Jul 2011 14:30:13 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p69EUDf8003975; Sat, 9 Jul 2011 14:30:13 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201107091430.p69EUDf8003975@svn.freebsd.org> From: Konstantin Belousov Date: Sat, 9 Jul 2011 14:30:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r223885 - head/sys/dev/pci X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 09 Jul 2011 14:30:13 -0000 Author: kib Date: Sat Jul 9 14:30:13 2011 New Revision: 223885 URL: http://svn.freebsd.org/changeset/base/223885 Log: Implement pci_find_class(9), the function to find a pci device by its class. Sponsored by: The FreeBSD Foundation Reviewed by: jhb MFC after: 1 week Modified: head/sys/dev/pci/pci.c head/sys/dev/pci/pcivar.h Modified: head/sys/dev/pci/pci.c ============================================================================== --- head/sys/dev/pci/pci.c Sat Jul 9 14:29:23 2011 (r223884) +++ head/sys/dev/pci/pci.c Sat Jul 9 14:30:13 2011 (r223885) @@ -347,6 +347,21 @@ pci_find_device(uint16_t vendor, uint16_ return (NULL); } +device_t +pci_find_class(uint8_t class, uint8_t subclass) +{ + struct pci_devinfo *dinfo; + + STAILQ_FOREACH(dinfo, &pci_devq, pci_links) { + if (dinfo->cfg.baseclass == class && + dinfo->cfg.subclass == subclass) { + return (dinfo->cfg.dev); + } + } + + return (NULL); +} + static int pci_printf(pcicfgregs *cfg, const char *fmt, ...) { Modified: head/sys/dev/pci/pcivar.h ============================================================================== --- head/sys/dev/pci/pcivar.h Sat Jul 9 14:29:23 2011 (r223884) +++ head/sys/dev/pci/pcivar.h Sat Jul 9 14:30:13 2011 (r223885) @@ -457,6 +457,7 @@ pci_msix_count(device_t dev) device_t pci_find_bsf(uint8_t, uint8_t, uint8_t); device_t pci_find_dbsf(uint32_t, uint8_t, uint8_t, uint8_t); device_t pci_find_device(uint16_t, uint16_t); +device_t pci_find_class(uint8_t class, uint8_t subclass); /* Can be used by drivers to manage the MSI-X table. */ int pci_pending_msix(device_t dev, u_int index);