staging: comedi: drivers: move comedi_async 'cur_chan' tracking into the core
authorH Hartley Sweeten <hsweeten@visionengravers.com>
Fri, 31 Oct 2014 16:49:31 +0000 (09:49 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 4 Nov 2014 00:31:24 +0000 (16:31 -0800)
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>
drivers/staging/comedi/drivers.c
drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
drivers/staging/comedi/drivers/adl_pci9118.c
drivers/staging/comedi/drivers/adv_pci1710.c
drivers/staging/comedi/drivers/ni_mio_common.c
drivers/staging/comedi/drivers/pcl812.c
drivers/staging/comedi/drivers/pcl816.c
drivers/staging/comedi/drivers/pcl818.c
drivers/staging/comedi/drivers/rtd520.c

index ff2df85..9c55dc7 100644 (file)
@@ -341,8 +341,15 @@ void comedi_inc_scan_progress(struct comedi_subdevice *s,
                              unsigned int num_bytes)
 {
        struct comedi_async *async = s->async;
+       struct comedi_cmd *cmd = &async->cmd;
        unsigned int scan_length = comedi_bytes_per_scan(s);
 
+       /* track the 'cur_chan' for non-SDF_PACKED subdevices */
+       if (!(s->subdev_flags & SDF_PACKED)) {
+               async->cur_chan += comedi_bytes_to_samples(s, num_bytes);
+               async->cur_chan %= cmd->chanlist_len;
+       }
+
        async->scan_progress += num_bytes;
        if (async->scan_progress >= scan_length) {
                async->scan_progress %= scan_length;