staging: comedi: Make INSN_BITS behavior consistent across drivers

Most comedi hardware drivers that support the INSN_BITS instruction
ignore the base channel (specified by insn->chanspec) and assume it is
0.  The base channel is supposed to affect how the mask (in data[0]) and
bits (in data[1]) are treated.  Bit 0 applies to the base channel, bit 1
applies to base channel plus 1, etc.

For subdevices with no more than 32 channels, this patch modifies the
chanspec and data before presenting it to the hardware driver, and
modifies the data bits read back by the hardware driver (into data[1]).
This makes it appear to the hardware driver that the base channel was
set to 0.

For subdevices with more than 32 channels, the instruction is left
unmodified, as it is assumed that the hardware driver takes note of the
base channel in this case in order to provide access beyond channel 31.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
1 file changed