staging: comedi: das6402: read analog input samples in interrupt handler
authorH Hartley Sweeten <hsweeten@visionengravers.com>
Thu, 13 Nov 2014 18:41:03 +0000 (11:41 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 26 Nov 2014 23:35:24 +0000 (15:35 -0800)
Currently the interrupt handler just clears the interrupt.

Add the code necessary to read the analog input samples when running
an async command.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/comedi/drivers/das6402.c

index 562d6ab90b7692ec30e804a4f202971cc7517ccd..047e9737d1fbeac854160de8e8a351ba26d0e86e 100644 (file)
@@ -193,12 +193,46 @@ static void das6402_enable_counter(struct comedi_device *dev, bool load)
        }
 }
 
+static unsigned int das6402_ai_read_sample(struct comedi_device *dev,
+                                          struct comedi_subdevice *s)
+{
+       unsigned int val;
+
+       val = inw(dev->iobase + DAS6402_AI_DATA_REG);
+       if (s->maxdata == 0x0fff)
+               val >>= 4;
+       return val;
+}
+
 static irqreturn_t das6402_interrupt(int irq, void *d)
 {
        struct comedi_device *dev = d;
+       struct comedi_subdevice *s = dev->read_subdev;
+       struct comedi_async *async = s->async;
+       struct comedi_cmd *cmd = &async->cmd;
+       unsigned int status;
+
+       status = inb(dev->iobase + DAS6402_STATUS_REG);
+       if ((status & DAS6402_STATUS_INT) == 0)
+               return IRQ_NONE;
+
+       if (status & DAS6402_STATUS_FFULL) {
+               async->events |= COMEDI_CB_OVERFLOW;
+       } else if (status & DAS6402_STATUS_FFNE) {
+               unsigned int val;
+
+               val = das6402_ai_read_sample(dev, s);
+               comedi_buf_write_samples(s, &val, 1);
+
+               if (cmd->stop_src == TRIG_COUNT &&
+                   async->scans_done >= cmd->stop_arg)
+                       async->events |= COMEDI_CB_EOA;
+       }
 
        das6402_clear_all_interrupts(dev);
 
+       comedi_handle_events(dev, s);
+
        return IRQ_HANDLED;
 }
 
@@ -367,7 +401,6 @@ static int das6402_ai_insn_read(struct comedi_device *dev,
 {
        unsigned int chan = CR_CHAN(insn->chanspec);
        unsigned int aref = CR_AREF(insn->chanspec);
-       unsigned int val;
        int ret;
        int i;
 
@@ -391,12 +424,7 @@ static int das6402_ai_insn_read(struct comedi_device *dev,
                if (ret)
                        break;
 
-               val = inw(dev->iobase + DAS6402_AI_DATA_REG);
-
-               if (s->maxdata == 0x0fff)
-                       val >>= 4;
-
-               data[i] = val;
+               data[i] = das6402_ai_read_sample(dev, s);
        }
 
        das6402_ai_clear_eoc(dev);
This page took 0.025508 seconds and 5 git commands to generate.