Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 18 Dec 2010 20:48:43 +0100
From:      Tijl Coosemans <tijl@freebsd.org>
To:        Paul B Mahol <onemda@gmail.com>
Cc:        svn-src-head@freebsd.org, Kostik Belousov <kostikbel@gmail.com>, svn-src-all@freebsd.org, src-committers@freebsd.org, John Baldwin <jhb@freebsd.org>
Subject:   Re: svn commit: r216518 - in head/sys/dev: if_ndis le malo sound/pci
Message-ID:  <201012182048.54969.tijl@freebsd.org>
In-Reply-To: <AANLkTim-9o3XmdeQF1%2BOfR8ToDzHqWyDJOR7sgziz5t5@mail.gmail.com>
References:  <201012181421.oBIELTSd093635@svn.freebsd.org> <AANLkTim-9o3XmdeQF1%2BOfR8ToDzHqWyDJOR7sgziz5t5@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
--nextPart1987300.O6GHZnZapO
Content-Type: multipart/mixed;
  boundary="Boundary-01=_cARDN/Cod0Bap/P"
Content-Transfer-Encoding: 7bit


--Boundary-01=_cARDN/Cod0Bap/P
Content-Type: Text/Plain;
  charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

On Saturday 18 December 2010 19:41:13 Paul B Mahol wrote:
> On 12/18/10, Tijl Coosemans <tijl@freebsd.org> wrote:
>> Author: tijl
>> Date: Sat Dec 18 14:21:28 2010
>> New Revision: 216518
>> URL: http://svn.freebsd.org/changeset/base/216518
>>
>> Log:
>>   Use convenience functions where possible instead of accessing the PCI
>>   configuration registers directly.
>>
>>   Remove pci_enable_io calls where they are redundant. The PCI bus driver
>>   will set the right bits when the corresponding bus resource is activat=
ed.
>>
>>   Remove redundant pci_* function calls from suspend/resume methods. The
>>   bus driver already saves and restores the PCI configuration.
>>
>>   Reviewed by:	jhb
>>   Approved by:	kib (mentor)
>=20
> Please revert change to if_ndis regarding introduction of pci_get_subvend=
or().
>=20
> You compare 16bit value with 32bit value - this will always fail.

Apologies. Instead of reverting, would the attached patch work for you?
It moves the function calls out of the while loop and makes it more clear
what subsys means.

--Boundary-01=_cARDN/Cod0Bap/P
Content-Type: text/x-patch;
  charset="ISO-8859-15";
  name="if_ndis.diff"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
	filename="if_ndis.diff"

diff --git a/sys/dev/if_ndis/if_ndis_pci.c b/sys/dev/if_ndis/if_ndis_pci.c
index ff93df3..2b9ad1e 100644
=2D-- a/sys/dev/if_ndis/if_ndis_pci.c
+++ b/sys/dev/if_ndis/if_ndis_pci.c
@@ -110,14 +110,20 @@ ndis_devcompare(bustype, t, dev)
 	struct ndis_pci_type	*t;
 	device_t		dev;
 {
+	uint16_t		vid, did;
+	uint32_t		subsys;
+
 	if (bustype !=3D PCIBus)
 		return(FALSE);
=20
+	vid =3D pci_get_vendor(dev);
+	did =3D pci_get_device(dev);
+	subsys =3D pci_get_subdevice(dev);
+	subsys =3D (subsys << 16) | pci_get_subvendor(dev);
+
 	while(t->ndis_name !=3D NULL) {
=2D		if ((pci_get_vendor(dev) =3D=3D t->ndis_vid) &&
=2D		    (pci_get_device(dev) =3D=3D t->ndis_did) &&
=2D		    (pci_get_subvendor(dev) =3D=3D t->ndis_subsys ||
=2D		     t->ndis_subsys =3D=3D 0)) {
+		if ((t->ndis_vid =3D=3D vid) && (t->ndis_did =3D=3D did) &&
+		    (t->ndis_subsys =3D=3D subsys || t->ndis_subsys =3D=3D 0)) {
 			device_set_desc(dev, t->ndis_name);
 			return(TRUE);
 		}
@@ -169,6 +175,8 @@ ndis_attach_pci(dev)
 	struct resource_list	*rl;
 	struct resource_list_entry	*rle;
 	struct drvdb_ent	*db;
+	uint16_t		vid, did;
+	uint32_t		subsys;
=20
 	sc =3D device_get_softc(dev);
 	unit =3D device_get_unit(dev);
@@ -300,14 +308,18 @@ ndis_attach_pci(dev)
=20
 	/* Figure out exactly which device we matched. */
=20
+	vid =3D pci_get_vendor(dev);
+	did =3D pci_get_device(dev);
+	subsys =3D pci_get_subdevice(dev);
+	subsys =3D (subsys << 16) | pci_get_subvendor(dev);
+
 	t =3D db->windrv_devlist;
=20
 	while(t->ndis_name !=3D NULL) {
=2D		if ((pci_get_vendor(dev) =3D=3D t->ndis_vid) &&
=2D		    (pci_get_device(dev) =3D=3D t->ndis_did)) {
+		if (t->ndis_vid =3D=3D vid && t->ndis_did =3D=3D did) {
 			if (t->ndis_subsys =3D=3D 0)
 				defidx =3D devidx;
=2D			else if (pci_get_subvendor(dev) =3D=3D t->ndis_subsys)
+			else if (t->ndis_subsys =3D=3D subsys)
 				break;
 		}
 		t++;

--Boundary-01=_cARDN/Cod0Bap/P--

--nextPart1987300.O6GHZnZapO
Content-Type: application/pgp-signature; name=signature.asc 
Content-Description: This is a digitally signed message part.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.16 (FreeBSD)

iF4EABEIAAYFAk0NECYACgkQfoCS2CCgtiu8OwD/Tds4r3N/PJpEsQnrWcTwEyNc
X9QyCOZaZvdVSiCyReIBAIi6nDaMF1EEEvhgXuGmcVDR8QzP1VHjUOWmOHzfvXDt
=JyA6
-----END PGP SIGNATURE-----

--nextPart1987300.O6GHZnZapO--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201012182048.54969.tijl>