staging: comedi: amplc_pc263: check bus type in detach routine
authorIan Abbott <abbotti@mev.co.uk>
Thu, 16 Aug 2012 10:14:19 +0000 (11:14 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 16 Aug 2012 18:33:16 +0000 (11:33 -0700)
When detaching the device in pc263_detach() mirror the bus type checks
performed by pc263_attach().  The existing tests are safe but rely on
dev->iobase being 0 when comedi_to_pci_dev(dev) is NULL.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/comedi/drivers/amplc_pc263.c

index a389aea4d2ad1cb9a9f65205b9ef102e35e2e06c..7aa82801e1800ff78731021d38057238d590a138 100644 (file)
@@ -313,15 +313,18 @@ static int __devinit pc263_attach_pci(struct comedi_device *dev,
 
 static void pc263_detach(struct comedi_device *dev)
 {
-       struct pci_dev *pcidev = comedi_to_pci_dev(dev);
+       const struct pc263_board *thisboard = comedi_board(dev);
 
-       if (pcidev) {
-               if (dev->iobase)
-                       comedi_pci_disable(pcidev);
-               pci_dev_put(pcidev);
-       } else {
+       if (is_isa_board(thisboard)) {
                if (dev->iobase)
                        release_region(dev->iobase, PC263_IO_SIZE);
+       } else if (is_pci_board(thisboard)) {
+               struct pci_dev *pcidev = comedi_to_pci_dev(dev);
+               if (pcidev) {
+                       if (dev->iobase)
+                               comedi_pci_disable(pcidev);
+                       pci_dev_put(pcidev);
+               }
        }
 }