staging: comedi: ni_mio_common: fix M Series ni_ai_insn_read() data mask
authorIan Abbott <abbotti@mev.co.uk>
Mon, 14 Nov 2016 20:16:21 +0000 (20:16 +0000)
committerSasha Levin <alexander.levin@verizon.com>
Fri, 13 Jan 2017 01:56:53 +0000 (20:56 -0500)
[ Upstream commit 655c4d442d1213b617926cc6d54e2a9a793fb46b ]

For NI M Series cards, the Comedi `insn_read` handler for the AI
subdevice is broken due to ANDing the value read from the AI FIFO data
register with an incorrect mask.  The incorrect mask clears all but the
most significant bit of the sample data.  It should preserve all the
sample data bits.  Correct it.

Fixes: 817144ae7fda ("staging: comedi: ni_mio_common: remove unnecessary use of 'board->adbits'")
Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Cc: <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
drivers/staging/comedi/drivers/ni_mio_common.c

index 4b8da862cd7ecdfb17fa6ad1056615b55b425152..f7bcefd46b5ee89540d042011ef035a5c9c2bfe0 100644 (file)
@@ -2079,7 +2079,7 @@ static int ni_ai_insn_read(struct comedi_device *dev,
                           unsigned int *data)
 {
        struct ni_private *devpriv = dev->private;
-       unsigned int mask = (s->maxdata + 1) >> 1;
+       unsigned int mask = s->maxdata;
        int i, n;
        unsigned signbits;
        unsigned int d;