[PATCH 03/10] staging: comedi: ni_mio_common: fix interrupt handler for dev->write_subdev

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



There may not be a dev->write_subdev, i.e. an analog output subdevice, that
supports async commands. If it doesn't exist the interrupt/dma will never
be enabled.  Fix ni_E_interrupt() so that the analog output subdevice is
only handled if it exists.

Signed-off-by: H Hartley Sweeten <hsweeten@xxxxxxxxxxxxxxxxxxx>
Cc: Ian Abbott <abbotti@xxxxxxxxx>
Cc: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
---
 drivers/staging/comedi/drivers/ni_mio_common.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c
index b2657de..5f6eedb 100644
--- a/drivers/staging/comedi/drivers/ni_mio_common.c
+++ b/drivers/staging/comedi/drivers/ni_mio_common.c
@@ -1386,11 +1386,10 @@ static void ack_b_interrupt(struct comedi_device *dev, unsigned short b_status)
 }
 
 static void handle_b_interrupt(struct comedi_device *dev,
+			       struct comedi_subdevice *s,
 			       unsigned short b_status,
 			       unsigned int ao_mite_status)
 {
-	struct comedi_subdevice *s = dev->write_subdev;
-
 	if (b_status == 0xffff)
 		return;
 	if (b_status & NISTC_AO_STATUS1_OVERRUN) {
@@ -5152,6 +5151,7 @@ static int ni_gpct_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
 static irqreturn_t ni_E_interrupt(int irq, void *d)
 {
 	struct comedi_device *dev = d;
+	struct comedi_subdevice *s_ao = dev->write_subdev;
 	unsigned short a_status;
 	unsigned short b_status;
 	unsigned int ai_mite_status = 0;
@@ -5178,12 +5178,11 @@ static irqreturn_t ni_E_interrupt(int irq, void *d)
 			ai_mite_status = mite_ack_linkc(devpriv->ai_mite_chan,
 							dev->read_subdev);
 
-		if (devpriv->ao_mite_chan) {
+		if (s_ao && devpriv->ao_mite_chan) {
 			ao_mite_status = mite_ack_linkc(devpriv->ao_mite_chan,
-							dev->write_subdev);
+							s_ao);
 			if (ao_mite_status & CHSR_LINKC)
-				mite_sync_dma(devpriv->ao_mite_chan,
-					      dev->write_subdev);
+				mite_sync_dma(devpriv->ao_mite_chan, s_ao);
 		}
 
 		spin_unlock_irqrestore(&devpriv->mite_channel_lock, flags_too);
@@ -5193,8 +5192,9 @@ static irqreturn_t ni_E_interrupt(int irq, void *d)
 	ack_b_interrupt(dev, b_status);
 	if ((a_status & NISTC_AI_STATUS1_INTA) || (ai_mite_status & CHSR_INT))
 		handle_a_interrupt(dev, a_status, ai_mite_status);
-	if ((b_status & NISTC_AO_STATUS1_INTB) || (ao_mite_status & CHSR_INT))
-		handle_b_interrupt(dev, b_status, ao_mite_status);
+	if (s_ao &&
+	    ((b_status & NISTC_AO_STATUS1_INTB) || (ao_mite_status & CHSR_INT)))
+		handle_b_interrupt(dev, s_ao, b_status, ao_mite_status);
 	handle_gpct_interrupt(dev, 0);
 	handle_gpct_interrupt(dev, 1);
 #ifdef PCIDMA
-- 
2.6.3

_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel



[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux