staging: comedi: das800: use comedi_async 'scans_done' to detect EOA
authorH Hartley Sweeten <hsweeten@visionengravers.com>
Wed, 5 Nov 2014 17:21:09 +0000 (10:21 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 5 Nov 2014 22:59:48 +0000 (14:59 -0800)
Remove the private data member 'count' and use the comedi_async 'scans_done'
member to detect the end-of-acquisition.

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/das800.c

index 55bc494838b53c53a6ab3fc0471598e80843cb26..e5bdc2423445dd94e78ed6cf3d48a56069d2d094 100644 (file)
@@ -219,7 +219,6 @@ static const struct das800_board das800_boards[] = {
 };
 
 struct das800_private {
-       unsigned int count;     /* number of data points left to be taken */
        unsigned int divisor1;  /* counter 1 value for timed conversions */
        unsigned int divisor2;  /* counter 2 value for timed conversions */
        unsigned int do_bits;   /* digital output bits */
@@ -286,9 +285,6 @@ static void das800_set_frequency(struct comedi_device *dev)
 
 static int das800_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
 {
-       struct das800_private *devpriv = dev->private;
-
-       devpriv->count = 0;
        das800_disable(dev);
        return 0;
 }
@@ -399,7 +395,6 @@ static int das800_ai_do_cmd(struct comedi_device *dev,
                            struct comedi_subdevice *s)
 {
        const struct das800_board *thisboard = dev->board_ptr;
-       struct das800_private *devpriv = dev->private;
        struct comedi_async *async = s->async;
        struct comedi_cmd *cmd = &async->cmd;
        unsigned int gain = CR_RANGE(cmd->chanlist[0]);
@@ -422,11 +417,6 @@ static int das800_ai_do_cmd(struct comedi_device *dev,
        gain &= 0xf;
        outb(gain, dev->iobase + DAS800_GAIN);
 
-       if (cmd->stop_src == TRIG_COUNT)
-               devpriv->count = cmd->stop_arg * cmd->chanlist_len;
-       else    /* TRIG_NONE */
-               devpriv->count = 0;
-
        /* enable auto channel scan, send interrupts on end of conversion
         * and set clock source to internal or external
         */
@@ -509,11 +499,13 @@ static irqreturn_t das800_interrupt(int irq, void *d)
                if (s->maxdata == 0x0fff)
                        val >>= 4;      /* 12-bit sample */
 
-               /* if there are more data points to collect */
-               if (cmd->stop_src == TRIG_NONE || devpriv->count > 0) {
-                       val &= s->maxdata;
-                       comedi_buf_write_samples(s, &val, 1);
-                       devpriv->count--;
+               val &= s->maxdata;
+               comedi_buf_write_samples(s, &val, 1);
+
+               if (cmd->stop_src == TRIG_COUNT &&
+                   async->scans_done >= cmd->stop_arg) {
+                       async->events |= COMEDI_CB_EOA;
+                       break;
                }
        }
 
@@ -524,9 +516,11 @@ static irqreturn_t das800_interrupt(int irq, void *d)
                return IRQ_HANDLED;
        }
 
-       if (cmd->stop_src == TRIG_NONE || devpriv->count > 0) {
-               /* Re-enable card's interrupt.
-                * We already have spinlock, so indirect addressing is safe */
+       if (!(async->events & COMEDI_CB_CANCEL_MASK)) {
+               /*
+                * Re-enable card's interrupt.
+                * We already have spinlock, so indirect addressing is safe
+                */
                das800_ind_write(dev, CONTROL1_INTE | devpriv->do_bits,
                                 CONTROL1);
                spin_unlock_irqrestore(&dev->spinlock, irq_flags);
@@ -534,7 +528,6 @@ static irqreturn_t das800_interrupt(int irq, void *d)
                /* otherwise, stop taking data */
                spin_unlock_irqrestore(&dev->spinlock, irq_flags);
                das800_disable(dev);
-               async->events |= COMEDI_CB_EOA;
        }
        comedi_handle_events(dev, s);
        return IRQ_HANDLED;