diff options
author | H Hartley Sweeten <hsweeten@visionengravers.com> | 2014-10-31 09:49:31 -0700 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2014-11-03 16:31:24 -0800 |
commit | f8736ca466e2014d6e8bad478fcc5e5cb0105af0 (patch) | |
tree | efb86b1332d953979f285fddf283be17cf64a3e5 /drivers/staging/comedi/drivers/pcl812.c | |
parent | c1b617e017f858505ce639a8dee4d096fbcb7b6b (diff) |
staging: comedi: drivers: move comedi_async 'cur_chan' tracking into the core
The commedi_async 'cur_chan' member is used to track the current position
in the chanlist for a scan. Currently only a couple comedi drivers use
this member.
For aeshtetics, move the 'cur_chan' tracking into the core for non-SDF_PACKED
subdevices. The 'cur_chan' will be updated after reading or writing samples
to the async buffer by comedi_inc_scan_progress(). All non-SDF_PACKED subdevices
will then automatiaclly track the 'cur_chan'.
Some of the drivers use the 'cur_chan' to detect the end of scan event when
counting scans. The COMEDI_CB_EOS event is automatically added by the core
when the end of scan is detected. The drivers just need to check if the
'cur_chan' is 0 to count the number of scans completed.
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>
Diffstat (limited to 'drivers/staging/comedi/drivers/pcl812.c')
-rw-r--r-- | drivers/staging/comedi/drivers/pcl812.c | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/drivers/staging/comedi/drivers/pcl812.c b/drivers/staging/comedi/drivers/pcl812.c index 10886070f48c..b13e9fb7a12e 100644 --- a/drivers/staging/comedi/drivers/pcl812.c +++ b/drivers/staging/comedi/drivers/pcl812.c @@ -843,12 +843,8 @@ static bool pcl812_ai_next_chan(struct comedi_device *dev, struct pcl812_private *devpriv = dev->private; struct comedi_cmd *cmd = &s->async->cmd; - s->async->cur_chan++; - if (s->async->cur_chan >= cmd->chanlist_len) { - s->async->cur_chan = 0; + if (s->async->cur_chan == 0) devpriv->ai_act_scan++; - s->async->events |= COMEDI_CB_EOS; - } if (cmd->stop_src == TRIG_COUNT && devpriv->ai_act_scan >= cmd->stop_arg) { @@ -864,6 +860,7 @@ static void pcl812_handle_eoc(struct comedi_device *dev, struct comedi_subdevice *s) { struct comedi_cmd *cmd = &s->async->cmd; + unsigned int chan = s->async->cur_chan; unsigned int next_chan; unsigned short val; @@ -877,10 +874,8 @@ static void pcl812_handle_eoc(struct comedi_device *dev, comedi_buf_write_samples(s, &val, 1); /* Set up next channel. Added by abbotti 2010-01-20, but untested. */ - next_chan = s->async->cur_chan + 1; - if (next_chan >= cmd->chanlist_len) - next_chan = 0; - if (cmd->chanlist[s->async->cur_chan] != cmd->chanlist[next_chan]) + next_chan = s->async->cur_chan; + if (cmd->chanlist[chan] != cmd->chanlist[next_chan]) pcl812_ai_set_chan_range(dev, cmd->chanlist[next_chan], 0); pcl812_ai_next_chan(dev, s); |