Skip to content

Commit 133dfbf

Browse files
bigguinessgregkh
authored andcommitted
staging: comedi: adv_pci1710: clarify the 'act_chanlist'
This driver saves the channel list of a scan in the private data and uses that list to check analog input samples for data dropout. Currently the channel numbers are shifted 12 bits so that they match the channel number in the samples that are read from the board. All of the shifts make the driver a bit harder to follow. Store the channel numbers directly to the 'act_chanlist' and shift the sample value instead when checking for the dropout. Add a comment for clarity. Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Reviewed-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent e4451ee commit 133dfbf

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

drivers/staging/comedi/drivers/adv_pci1710.c

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -293,11 +293,16 @@ static int pci171x_ai_dropout(struct comedi_device *dev,
293293
struct pci1710_private *devpriv = dev->private;
294294

295295
if (!board->is_pci1713) {
296-
if ((val & 0xf000) != devpriv->act_chanlist[chan]) {
296+
/*
297+
* The upper 4 bits of the 16-bit sample are the channel number
298+
* that the sample was acquired from. Verify that this channel
299+
* number matches the expected channel number.
300+
*/
301+
val >>= 12;
302+
if (val != devpriv->act_chanlist[chan]) {
297303
dev_err(dev->class_dev,
298304
"A/D data droput: received from channel %d, expected %d\n",
299-
(val >> 12) & 0xf,
300-
(devpriv->act_chanlist[chan] >> 12) & 0xf);
305+
val, devpriv->act_chanlist[chan]);
301306
return -ENODATA;
302307
}
303308
}
@@ -386,13 +391,10 @@ static void setup_channel_list(struct comedi_device *dev,
386391
if (CR_AREF(chanlist[i]) == AREF_DIFF)
387392
range |= 0x0020;
388393
outw(range, dev->iobase + PCI171x_RANGE); /* select gain */
389-
devpriv->act_chanlist[i] =
390-
(CR_CHAN(chanlist[i]) << 12) & 0xf000;
391-
}
392-
for ( ; i < n_chan; i++) { /* store remainder of channel list */
393-
devpriv->act_chanlist[i] =
394-
(CR_CHAN(chanlist[i]) << 12) & 0xf000;
394+
devpriv->act_chanlist[i] = CR_CHAN(chanlist[i]);
395395
}
396+
for ( ; i < n_chan; i++) /* store remainder of channel list */
397+
devpriv->act_chanlist[i] = CR_CHAN(chanlist[i]);
396398

397399
devpriv->ai_et_MuxVal =
398400
CR_CHAN(chanlist[0]) | (CR_CHAN(chanlist[seglen - 1]) << 8);

0 commit comments

Comments
 (0)