From: Ian Abbott Date: Wed, 20 Jan 2010 13:04:45 +0000 (+0000) Subject: Staging: comedi: pcl816: Correct AI scan counting X-Git-Tag: v2.6.34-rc1~10^2~1^2~179 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=13de4f000ec491b16a820e4ed59de2c98b7807be;p=profile%2Fivi%2Fkernel-adaptation-intel-automotive.git Staging: comedi: pcl816: Correct AI scan counting 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 Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/comedi/drivers/pcl816.c b/drivers/staging/comedi/drivers/pcl816.c index 852fe24..5c88ddc 100644 --- a/drivers/staging/comedi/drivers/pcl816.c +++ b/drivers/staging/comedi/drivers/pcl816.c @@ -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;