patch from Ian Abbott <abbotti@mev.co.uk>, who says:
authorFrank Mori Hess <fmhess@speakeasy.net>
Tue, 25 Jan 2005 23:44:43 +0000 (23:44 +0000)
committerFrank Mori Hess <fmhess@speakeasy.net>
Tue, 25 Jan 2005 23:44:43 +0000 (23:44 +0000)
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.

comedi/drivers/amplc_pc236.c
comedi/drivers/amplc_pc263.c

index cce66bb91e83d767fb0599fbe49e9786efcb2436..41f6bff9e015bddf617d5d5d81812d739c949aab 100644 (file)
@@ -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)
index b985721908059e668993dcfde4a35799b352e8fd..9a260b242947171c66ff0d68c2f38b2d63d60cf7 100644 (file)
@@ -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)