staging: comedi: Make INSN_BITS behavior consistent across drivers
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 <9e6ba6483b6a3e14d61f7c987e72ecb5b46122d6@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <4645f7897fd33786a2ee1264d590b3c400559d85@suse.de>

TeamVee-Kanas/android_kernel_samsung_kanas,KristFoundation/Programs,KristFoundation/Programs,KristFoundation/Programs,TeamVee-Kanas/android_kernel_samsung_kanas,TeamVee-Kanas/android_kernel_samsung_kanas,KristFoundation/Programs,TeamVee-Kanas/android_kernel_samsung_kanas,KristFoundation/Programs,KristFoundation/Programs,TeamVee-Kanas/android_kernel_samsung_kanas