summaryrefslogtreecommitdiff
path: root/drivers/staging/comedi/drivers/adv_pci1710.c
diff options
context:
space:
mode:
authorH Hartley Sweeten <hsweeten@visionengravers.com>2015-01-20 14:53:20 -0700
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2015-01-25 19:59:12 +0800
commit133dfbfb226db01d0548efcd712ba11c5f208922 (patch)
tree542bb366dc75ee9996779a58b6ed62da8594093d /drivers/staging/comedi/drivers/adv_pci1710.c
parente4451eeb456550d1fa1641ce369c1b914b02d225 (diff)
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>
Diffstat (limited to 'drivers/staging/comedi/drivers/adv_pci1710.c')
-rw-r--r--drivers/staging/comedi/drivers/adv_pci1710.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/drivers/staging/comedi/drivers/adv_pci1710.c b/drivers/staging/comedi/drivers/adv_pci1710.c
index 9bbdef8da6a8..0927bbe48c87 100644
--- a/drivers/staging/comedi/drivers/adv_pci1710.c
+++ b/drivers/staging/comedi/drivers/adv_pci1710.c
@@ -293,11 +293,16 @@ static int pci171x_ai_dropout(struct comedi_device *dev,
struct pci1710_private *devpriv = dev->private;
if (!board->is_pci1713) {
- if ((val & 0xf000) != devpriv->act_chanlist[chan]) {
+ /*
+ * The upper 4 bits of the 16-bit sample are the channel number
+ * that the sample was acquired from. Verify that this channel
+ * number matches the expected channel number.
+ */
+ val >>= 12;
+ if (val != devpriv->act_chanlist[chan]) {
dev_err(dev->class_dev,
"A/D data droput: received from channel %d, expected %d\n",
- (val >> 12) & 0xf,
- (devpriv->act_chanlist[chan] >> 12) & 0xf);
+ val, devpriv->act_chanlist[chan]);
return -ENODATA;
}
}
@@ -386,13 +391,10 @@ static void setup_channel_list(struct comedi_device *dev,
if (CR_AREF(chanlist[i]) == AREF_DIFF)
range |= 0x0020;
outw(range, dev->iobase + PCI171x_RANGE); /* select gain */
- devpriv->act_chanlist[i] =
- (CR_CHAN(chanlist[i]) << 12) & 0xf000;
- }
- for ( ; i < n_chan; i++) { /* store remainder of channel list */
- devpriv->act_chanlist[i] =
- (CR_CHAN(chanlist[i]) << 12) & 0xf000;
+ devpriv->act_chanlist[i] = CR_CHAN(chanlist[i]);
}
+ for ( ; i < n_chan; i++) /* store remainder of channel list */
+ devpriv->act_chanlist[i] = CR_CHAN(chanlist[i]);
devpriv->ai_et_MuxVal =
CR_CHAN(chanlist[0]) | (CR_CHAN(chanlist[seglen - 1]) << 8);