staging: comedi: ni_labpc: fix common detach
authorIan Abbott <abbotti@mev.co.uk>
Fri, 15 Mar 2013 13:39:52 +0000 (13:39 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 15 Mar 2013 16:17:21 +0000 (09:17 -0700)
`labpc_common_detach()` calls `comedi_pci_disable()` unconditionally.
That's okay for PCI devices and harmless for ISA devices (as the
`hw_dev` member will be NULL so `comedi_to_pci_dev()` will return NULL
and `comedi_pci_disable()` checks for that), but it is disastrous for
PCMCIA devices.  Those are managed by the "ni_labpc_cs" module but it
calls this `labpc_common_detach()` and the `hw_dev` member will be
pointing to the `struct device` embedded in a `struct pcmcia_device` in
that case.  That's enough to confuse `comedi_pci_disable()` into
thinking it's a valid PCI device to be disabled.

Use the private board information (`thisboard`) to make sure it is a PCI
device before calling `comedi_pci_disable()`.

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

index 62ec39dea97dddfa134eacec3eb13506b97467bf..152dc844fa96bc5645f37d99648a5266884add71 100644 (file)
@@ -804,7 +804,8 @@ void labpc_common_detach(struct comedi_device *dev)
                mite_unsetup(devpriv->mite);
                mite_free(devpriv->mite);
        }
-       comedi_pci_disable(dev);
+       if (thisboard->bustype == pci_bustype)
+               comedi_pci_disable(dev);
 #endif
 };
 EXPORT_SYMBOL_GPL(labpc_common_detach);