summaryrefslogtreecommitdiff
path: root/drivers/staging/comedi/drivers/addi_apci_2032.c
diff options
context:
space:
mode:
authorIan Abbott <abbotti@mev.co.uk>2012-12-03 18:15:40 +0000
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-01-07 14:10:01 -0800
commit0774c2b5c1e0025cb016393d8552171c0ec55c39 (patch)
tree040be88b5ec40da187006dac55fbf2704bda3c76 /drivers/staging/comedi/drivers/addi_apci_2032.c
parentd9f5420268ca9b2bbe62f14757fac3e10eaf1ebf (diff)
staging: comedi: addi_apci_2032: interrupt safety change
Put the hardware into a safe state before enabling the interrupt. In the interrupt routine, check the device has been fully configured by checking `dev->attached`. In particular, `dev->read_subdev` could be NULL early on and although the hardware's status register should indicate no interrupt has occurred (since it's been put into a safe state), it's better not to rely on it. Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/comedi/drivers/addi_apci_2032.c')
-rw-r--r--drivers/staging/comedi/drivers/addi_apci_2032.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/drivers/staging/comedi/drivers/addi_apci_2032.c b/drivers/staging/comedi/drivers/addi_apci_2032.c
index 8f8d3e95fc78..3b5e1d74d129 100644
--- a/drivers/staging/comedi/drivers/addi_apci_2032.c
+++ b/drivers/staging/comedi/drivers/addi_apci_2032.c
@@ -237,6 +237,9 @@ static irqreturn_t apci2032_interrupt(int irq, void *d)
struct comedi_subdevice *s = dev->read_subdev;
unsigned int val;
+ if (!dev->attached)
+ return IRQ_NONE;
+
/* Check if VCC OR CC interrupt has occurred */
val = inl(dev->iobase + APCI2032_STATUS_REG) & APCI2032_STATUS_IRQ;
if (!val)
@@ -281,6 +284,7 @@ static int apci2032_auto_attach(struct comedi_device *dev,
if (ret)
return ret;
dev->iobase = pci_resource_start(pcidev, 1);
+ apci2032_reset(dev);
if (pcidev->irq > 0) {
ret = request_irq(pcidev->irq, apci2032_interrupt,
@@ -329,7 +333,6 @@ static int apci2032_auto_attach(struct comedi_device *dev,
s->type = COMEDI_SUBD_UNUSED;
}
- apci2032_reset(dev);
return 0;
}