From: Frank Mori Hess Date: Tue, 25 Jan 2005 23:44:43 +0000 (+0000) Subject: patch from Ian Abbott , who says: X-Git-Tag: r0_7_70~59 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=3ff3f22fa08a14c4fd2a040268570bebd5e1742f;p=comedi.git patch from Ian Abbott , who says: This patch fixes a harmless logical error in the _attach routines of the amplc_pc236 and amplc_pc263 drivers that I noticed while looking at the pci_for_each_dev stuff. Also, now that the drivers ar using pci_find_device instead of pci_for_each_dev, the patch offloads some of the searching for a matching PCI device to the pci_find_device function. The bug is just after the loop that finds the PCI device ID table entry that matches the comedi board name. The test for reaching the end of the PCI device ID table without finding a match was incorrect. I say the bug is harmless because there would have to be another bug somewhere else to trigger this bug. --- diff --git a/comedi/drivers/amplc_pc236.c b/comedi/drivers/amplc_pc236.c index cce66bb9..41f6bff9 100644 --- a/comedi/drivers/amplc_pc236.c +++ b/comedi/drivers/amplc_pc236.c @@ -192,24 +192,22 @@ static int pc236_attach(comedi_device *dev,comedi_devconfig *it) if (pci_id->driver_data == thisboard->model) break; } - if (pci_id->driver_data != thisboard->model) { + if (pci_id->vendor == 0) { printk("bug! cannot determine board type!\n"); return -EINVAL; } /* Look for matching PCI device. */ - for(pci_dev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, NULL); pci_dev != NULL ; - pci_dev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, pci_dev)) { + for(pci_dev = pci_find_device(pci_id->vendor, pci_id->device, + NULL); pci_dev != NULL; + pci_dev = pci_find_device(pci_id->vendor, + pci_id->device, pci_dev)) { /* If bus/slot specified, check them. */ if (bus || slot) { if (bus != pci_dev->bus->number || slot != PCI_SLOT(pci_dev->devfn)) continue; } - if (pci_dev->vendor != pci_id->vendor) - continue; - if (pci_dev->device != pci_id->device) - continue; #if 0 if (pci_id->subvendor != PCI_ANY_ID) { if (pci_dev->subsystem_vendor != pci_id->subvendor) diff --git a/comedi/drivers/amplc_pc263.c b/comedi/drivers/amplc_pc263.c index b9857219..9a260b24 100644 --- a/comedi/drivers/amplc_pc263.c +++ b/comedi/drivers/amplc_pc263.c @@ -163,24 +163,22 @@ static int pc263_attach(comedi_device *dev,comedi_devconfig *it) if (pci_id->driver_data == thisboard->model) break; } - if (pci_id->driver_data != thisboard->model) { + if (pci_id->vendor == 0) { printk("bug! cannot determine board type!\n"); return -EINVAL; } /* Look for matching PCI device. */ - for(pci_dev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, NULL); pci_dev != NULL ; - pci_dev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, pci_dev)) { + for(pci_dev = pci_find_device(pci_id->vendor, pci_id->device, + NULL); pci_dev != NULL; + pci_dev = pci_find_device(pci_id->vendor, + pci_id->device, pci_dev)) { /* If bus/slot specified, check them. */ if (bus || slot) { if (bus != pci_dev->bus->number || slot != PCI_SLOT(pci_dev->devfn)) continue; } - if (pci_dev->vendor != pci_id->vendor) - continue; - if (pci_dev->device != pci_id->device) - continue; #if 0 if (pci_id->subvendor != PCI_ANY_ID) { if (pci_dev->subsystem_vendor != pci_id->subvendor)