Commit af031edf authored by H Hartley Sweeten's avatar H Hartley Sweeten Committed by Greg Kroah-Hartman

staging: comedi: adl_pci9111: cleanup pci9111_ai_munge()

The shift, maxdata, and invert values, used to handle the 12-/16-bit
analog input differences, can be calculated based on the subdevice
maxdata value.
Signed-off-by: default avatarH Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 2873ea81
...@@ -809,21 +809,15 @@ static void pci9111_ai_munge(struct comedi_device *dev, ...@@ -809,21 +809,15 @@ static void pci9111_ai_munge(struct comedi_device *dev,
unsigned int num_bytes, unsigned int num_bytes,
unsigned int start_chan_index) unsigned int start_chan_index)
{ {
unsigned int i, num_samples = num_bytes / sizeof(short);
short *array = data; short *array = data;
int resolution = unsigned int maxdata = s->maxdata;
((struct pci9111_board *)dev->board_ptr)->ai_resolution; unsigned int invert = (maxdata + 1) >> 1;
unsigned int shift = (maxdata == 0xffff) ? 0 : 4;
for (i = 0; i < num_samples; i++) { unsigned int num_samples = num_bytes / sizeof(short);
if (resolution == PCI9111_HR_AI_RESOLUTION) unsigned int i;
array[i] =
(array[i] & PCI9111_HR_AI_RESOLUTION_MASK) ^ for (i = 0; i < num_samples; i++)
PCI9111_HR_AI_RESOLUTION_2_CMP_BIT; array[i] = ((array[i] >> shift) & maxdata) ^ invert;
else
array[i] =
((array[i] >> 4) & PCI9111_AI_RESOLUTION_MASK) ^
PCI9111_AI_RESOLUTION_2_CMP_BIT;
}
} }
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment