Skip to content

Commit

Permalink
Staging: comedi: pcl816: Correct AI scan counting
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Ian Abbott authored and Greg Kroah-Hartman committed Mar 4, 2010
1 parent 7edfa10 commit 13de4f0
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion drivers/staging/comedi/drivers/pcl816.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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++;
}

Expand Down Expand Up @@ -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++;
}

Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 13de4f0

Please sign in to comment.