staging: comedi: fix scan_end_arg == chanlist_len assumption
authorIan Abbott <abbotti@mev.co.uk>
Wed, 12 Nov 2014 16:00:48 +0000 (16:00 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 26 Nov 2014 23:35:24 +0000 (15:35 -0800)
commitaf57d89e162a18676cb87825e193125e40f4c34b
tree81f839831b002a70ba53748d0379757aeeadbb2c
parent921890b0d674cece0a9becf8f38a14deaef6d3d2
staging: comedi: fix scan_end_arg == chanlist_len assumption

Some comedi drivers allow the `scan_end_arg` value of an asynchronous
command to be a multiple (> 1) of the `chanlist_len` although most
require them to be the same value.

`comedi_bytes_per_scan()` is incorrectly using `chanlist_len` as the
length of the scan.  Change it to use `scan_end_arg`.

`comedi_nsamples_left()` is incorrectly using `cur_chan` as the current
sample position in the scan (it is actually the current position in the
channel list).  Change it to use the actual sample position in the scan.
(Unfortunately we only have the current scan position in bytes currently,
so convert that to a sample position.)

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/comedi/drivers.c