From: Ian Abbott Date: Tue, 14 Aug 2012 15:31:29 +0000 (+0100) Subject: staging: comedi: amplc_dio200: check bus type in detach routine X-Git-Tag: upstream/snapshot3+hdmi~6593^2~938 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b7518888afc14e3d1e988837fef4471cd2b3c820;p=platform%2Fadaptation%2Frenesas_rcar%2Frenesas_kernel.git staging: comedi: amplc_dio200: check bus type in detach routine When detaching the device in dio200_detach() mirror the bus type checks performed by dio200_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 Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/comedi/drivers/amplc_dio200.c b/drivers/staging/comedi/drivers/amplc_dio200.c index 0905e40..7a61831 100644 --- a/drivers/staging/comedi/drivers/amplc_dio200.c +++ b/drivers/staging/comedi/drivers/amplc_dio200.c @@ -1417,7 +1417,6 @@ static int __devinit dio200_attach_pci(struct comedi_device *dev, static void dio200_detach(struct comedi_device *dev) { const struct dio200_board *thisboard = comedi_board(dev); - struct pci_dev *pcidev = comedi_to_pci_dev(dev); const struct dio200_layout_struct *layout; unsigned n; @@ -1442,13 +1441,16 @@ static void dio200_detach(struct comedi_device *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, DIO200_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); + } } }