Skip to content

Commit abe46b8

Browse files
ian-abbottgregkh
authored andcommitted
staging: comedi: adv_pci1710: fix AI INSN_READ for non-zero channel
Reading of analog input channels by the `INSN_READ` comedi instruction is broken for all except channel 0. `pci171x_ai_insn_read()` calls `pci171x_ai_read_sample()` with the wrong value for the third parameter. It is supposed to be the current index in a channel list (which is always of length 1 in this case, so the index should be 0), but instead it is passing the actual channel number. `pci171x_ai_read_sample()` checks the channel number encoded in the raw sample value read from the hardware matches the channel number stored in the specified index of the previously set up channel list and returns `-ENODATA` if it doesn't match. Since the index should always be 0 in this case, the match will fail unless the channel number is also 0. Fix it by passing 0 as the channel index. Note that when the bug first appeared, it was `pci171x_ai_dropout()` that was called with the wrong parameter value. `pci171x_ai_dropout()` got replaced with `pci171x_ai_read_sample()` in commit 7fd2dae ("staging: comedi: adv_pci1710: introduce pci171x_ai_read_sample()"). Fixes: 16c7eb6 ("staging: comedi: adv_pci1710: always enable PCI171x_PARANOIDCHECK code") Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Cc: stable <stable@vger.kernel.org> # 3.16+ Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 981c1fe commit abe46b8

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

drivers/staging/comedi/drivers/adv_pci1710.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,6 @@ static int pci171x_ai_insn_read(struct comedi_device *dev,
426426
unsigned int *data)
427427
{
428428
struct pci1710_private *devpriv = dev->private;
429-
unsigned int chan = CR_CHAN(insn->chanspec);
430429
int ret = 0;
431430
int i;
432431

@@ -447,7 +446,7 @@ static int pci171x_ai_insn_read(struct comedi_device *dev,
447446
if (ret)
448447
break;
449448

450-
ret = pci171x_ai_read_sample(dev, s, chan, &val);
449+
ret = pci171x_ai_read_sample(dev, s, 0, &val);
451450
if (ret)
452451
break;
453452

0 commit comments

Comments
 (0)