From owner-svn-src-head@FreeBSD.ORG Sat Jul 9 19:17:02 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 1E876106564A; Sat, 9 Jul 2011 19:17:02 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from mail.zoral.com.ua (mx0.zoral.com.ua [91.193.166.200]) by mx1.freebsd.org (Postfix) with ESMTP id AF2128FC27; Sat, 9 Jul 2011 19:17:01 +0000 (UTC) Received: from deviant.kiev.zoral.com.ua (root@deviant.kiev.zoral.com.ua [10.1.1.148]) by mail.zoral.com.ua (8.14.2/8.14.2) with ESMTP id p69JGrew020173 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sat, 9 Jul 2011 22:16:53 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: from deviant.kiev.zoral.com.ua (kostik@localhost [127.0.0.1]) by deviant.kiev.zoral.com.ua (8.14.4/8.14.4) with ESMTP id p69JGqhc025128; Sat, 9 Jul 2011 22:16:52 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: (from kostik@localhost) by deviant.kiev.zoral.com.ua (8.14.4/8.14.4/Submit) id p69JGqo0025127; Sat, 9 Jul 2011 22:16:52 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: deviant.kiev.zoral.com.ua: kostik set sender to kostikbel@gmail.com using -f Date: Sat, 9 Jul 2011 22:16:52 +0300 From: Kostik Belousov To: Warner Losh Message-ID: <20110709191652.GA22221@deviant.kiev.zoral.com.ua> References: <201107091430.p69EUDf8003975@svn.freebsd.org> <307FA901-53F0-4622-98AE-329FAE9762A1@bsdimp.com> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="liOOAslEiF7prFVr" Content-Disposition: inline In-Reply-To: <307FA901-53F0-4622-98AE-329FAE9762A1@bsdimp.com> User-Agent: Mutt/1.4.2.3i X-Virus-Scanned: clamav-milter 0.95.2 at skuns.kiev.zoral.com.ua X-Virus-Status: Clean X-Spam-Status: No, score=-3.3 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00, DNS_FROM_OPENWHOIS autolearn=no version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on skuns.kiev.zoral.com.ua Cc: svn-src-head@FreeBSD.org, svn-src-all@FreeBSD.org, src-committers@FreeBSD.org Subject: Re: 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 19:17:02 -0000 --liOOAslEiF7prFVr Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sat, Jul 09, 2011 at 12:56:10PM -0600, Warner Losh wrote: > Should't this be called 'pci_find_first_class()"? Also, can you add a > man page for it, or at least document what it is supposed to be used > for in the code? > > Warenr Sure, I will add a man page. Regarding the name, the intended use is to look up some unique devices on the hierarchy, like HOST-PCI bridge, or (used in the driver which requires this function) PCI-ISA bridge. It is known that device belonging to the supplied class is unique in the whole PCI buses hierarchy on the machine where the driver is attaching. 'First' there probably cannot be given any strong sense, since it would be a first device in some unspecified order. >=20 > On Jul 9, 2011, at 8:30 AM, Konstantin Belousov wrote: >=20 > > Author: kib > > Date: Sat Jul 9 14:30:13 2011 > > New Revision: 223885 > > URL: http://svn.freebsd.org/changeset/base/223885 > >=20 > > Log: > > Implement pci_find_class(9), the function to find a pci device by its = class. > >=20 > > Sponsored by: The FreeBSD Foundation > > Reviewed by: jhb > > MFC after: 1 week > >=20 > > Modified: > > head/sys/dev/pci/pci.c > > head/sys/dev/pci/pcivar.h > >=20 > > Modified: head/sys/dev/pci/pci.c > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D > > --- 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); > > } > >=20 > > +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 =3D=3D class && > > + dinfo->cfg.subclass =3D=3D subclass) { > > + return (dinfo->cfg.dev); > > + } > > + } > > + > > + return (NULL); > > +} > > + > > static int > > pci_printf(pcicfgregs *cfg, const char *fmt, ...) > > { > >=20 > > Modified: head/sys/dev/pci/pcivar.h > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D > > --- 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); > >=20 > > /* Can be used by drivers to manage the MSI-X table. */ > > int pci_pending_msix(device_t dev, u_int index); > >=20 > >=20 >=20 --liOOAslEiF7prFVr Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (FreeBSD) iEYEARECAAYFAk4YqSQACgkQC3+MBN1Mb4jX1QCg1LnpuPrWU54dkV0G6oMXp4Qr 1WcAoL1BFCNS4L8lEoO5w/N9atolc0rG =8v3Y -----END PGP SIGNATURE----- --liOOAslEiF7prFVr--