Staging: comedi: pcl816: Correct AI scan counting
authorIan Abbott <abbotti@mev.co.uk>
Wed, 20 Jan 2010 13:04:45 +0000 (13:04 +0000)
committerGreg Kroah-Hartman <gregkh@suse.de>
Thu, 4 Mar 2010 00:42:47 +0000 (16:42 -0800)
For AI commands, the scan counter should be updated after every
scan.  In DMA mode, it was being updated after every repeated
segment of the channel list.  In non-DMA mode, it was being updated
after every sample.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/staging/comedi/drivers/pcl816.c

index 852fe2458fdc16682c1953de9efc974e5806654f..5c88ddc1fc0574ffc431fac058e02658d5bf7936 100644 (file)
@@ -202,6 +202,7 @@ struct pcl816_private {
        unsigned int ai_act_chanlist[16];       /*  MUX setting for actual AI operations */
        unsigned int ai_act_chanlist_len;       /*  how long is actual MUX list */
        unsigned int ai_act_chanlist_pos;       /*  actual position in MUX list */
+       unsigned int ai_n_chan;         /*  how many channels per scan */
        unsigned int ai_poll_ptr;       /*  how many sampes transfer poll */
        struct comedi_subdevice *sub_ai;        /*  ptr to AI subdevice */
 #ifdef unused
@@ -320,7 +321,9 @@ static irqreturn_t interrupt_pcl816_ai_mode13_int(int irq, void *d)
        if (++devpriv->ai_act_chanlist_pos >= devpriv->ai_act_chanlist_len)
                devpriv->ai_act_chanlist_pos = 0;
 
-       if (s->async->cur_chan == 0) {
+       s->async->cur_chan++;
+       if (s->async->cur_chan >= devpriv->ai_n_chan) {
+               s->async->cur_chan = 0;
                devpriv->ai_act_scan++;
        }
 
@@ -353,6 +356,11 @@ static void transfer_from_dma_buf(struct comedi_device *dev,
                if (++devpriv->ai_act_chanlist_pos >=
                    devpriv->ai_act_chanlist_len) {
                        devpriv->ai_act_chanlist_pos = 0;
+               }
+
+               s->async->cur_chan++;
+               if (s->async->cur_chan >= devpriv->ai_n_chan) {
+                       s->async->cur_chan = 0;
                        devpriv->ai_act_scan++;
                }
 
@@ -647,6 +655,7 @@ static int pcl816_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
                return -EINVAL;
        udelay(1);
 
+       devpriv->ai_n_chan = cmd->chanlist_len;
        devpriv->ai_act_scan = 0;
        s->async->cur_chan = 0;
        devpriv->irq_blocked = 1;