From 4485b7e74acb0bf475798971b76b6cdd3269a6fd Mon Sep 17 00:00:00 2001 From: Tijl Coosemans Date: Sun, 19 Dec 2010 11:14:34 +0000 Subject: 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) --- sys/dev/if_ndis/if_ndis_pci.c | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/sys/dev/if_ndis/if_ndis_pci.c b/sys/dev/if_ndis/if_ndis_pci.c index ff93df3fb341..2b9ad1ef3993 100644 --- 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 != 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++; -- cgit v1.2.3