Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 19 Dec 2010 11:14:34 +0000 (UTC)
From:      Tijl Coosemans <tijl@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r216558 - head/sys/dev/if_ndis
Message-ID:  <201012191114.oBJBEYob073154@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: tijl
Date: Sun Dec 19 11:14:34 2010
New Revision: 216558
URL: http://svn.freebsd.org/changeset/base/216558

Log:
  Fix a bug introduced in r216518. The ndis_subsys field holds the PCI
  subdevice ID in addition to the subvendor ID.
  
  Reported by:	Paul B Mahol 'onemda gmail com'
  Approved by:	kib (mentor)

Modified:
  head/sys/dev/if_ndis/if_ndis_pci.c

Modified: head/sys/dev/if_ndis/if_ndis_pci.c
==============================================================================
--- head/sys/dev/if_ndis/if_ndis_pci.c	Sun Dec 19 10:36:06 2010	(r216557)
+++ head/sys/dev/if_ndis/if_ndis_pci.c	Sun Dec 19 11:14:34 2010	(r216558)
@@ -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 != PCIBus)
 		return(FALSE);
 
+	vid = pci_get_vendor(dev);
+	did = pci_get_device(dev);
+	subsys = pci_get_subdevice(dev);
+	subsys = (subsys << 16) | pci_get_subvendor(dev);
+
 	while(t->ndis_name != NULL) {
-		if ((pci_get_vendor(dev) == t->ndis_vid) &&
-		    (pci_get_device(dev) == t->ndis_did) &&
-		    (pci_get_subvendor(dev) == t->ndis_subsys ||
-		     t->ndis_subsys == 0)) {
+		if ((t->ndis_vid == vid) && (t->ndis_did == did) &&
+		    (t->ndis_subsys == subsys || t->ndis_subsys == 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;
 
 	sc = device_get_softc(dev);
 	unit = device_get_unit(dev);
@@ -300,14 +308,18 @@ ndis_attach_pci(dev)
 
 	/* Figure out exactly which device we matched. */
 
+	vid = pci_get_vendor(dev);
+	did = pci_get_device(dev);
+	subsys = pci_get_subdevice(dev);
+	subsys = (subsys << 16) | pci_get_subvendor(dev);
+
 	t = db->windrv_devlist;
 
 	while(t->ndis_name != NULL) {
-		if ((pci_get_vendor(dev) == t->ndis_vid) &&
-		    (pci_get_device(dev) == t->ndis_did)) {
+		if (t->ndis_vid == vid && t->ndis_did == did) {
 			if (t->ndis_subsys == 0)
 				defidx = devidx;
-			else if (pci_get_subvendor(dev) == t->ndis_subsys)
+			else if (t->ndis_subsys == subsys)
 				break;
 		}
 		t++;



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