aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIan Abbott2013-02-27 06:52:46 -0600
committerGreg Kroah-Hartman2013-03-03 16:09:07 -0600
commit544da4403b05e874e134919db7124def003ef7cf (patch)
tree7424e8d2dd995350b0218a5d2c63a6cb27c2ebba
parent5e6af63de116db55be85da4374441f7963d11281 (diff)
downloadkernel-common-544da4403b05e874e134919db7124def003ef7cf.tar.gz
kernel-common-544da4403b05e874e134919db7124def003ef7cf.tar.xz
kernel-common-544da4403b05e874e134919db7124def003ef7cf.zip
staging: comedi: ni_labpc: set up command4 register *after* command3
Commit 22056e2b46246d97ff0f7c6e21a77b8daa07f02c upstream. Tuomas <tvainikk _at_ gmail _dot_ com> reported problems getting meaningful output from a Lab-PC+ in differential mode for AI cmds, but AI insn reads gave correct readings. He tracked it down to two problems, one of which is addressed by this patch. It seems that writing to the command3 register after writing to the command4 register in `labpc_ai_cmd()` messes up the differential reference bit setting in the command4 register. Set up the command4 register after the command3 register (as in `labpc_ai_rinsn()`) to avoid the problem. Thanks to Tuomas for suggesting the fix. Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/staging/comedi/drivers/ni_labpc.c31
1 files changed, 16 insertions, 15 deletions
diff --git a/drivers/staging/comedi/drivers/ni_labpc.c b/drivers/staging/comedi/drivers/ni_labpc.c
index 9b204b4d1e7..897359d79e5 100644
--- a/drivers/staging/comedi/drivers/ni_labpc.c
+++ b/drivers/staging/comedi/drivers/ni_labpc.c
@@ -1259,21 +1259,6 @@ static int labpc_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
1259 devpriv->write_byte(devpriv->command1_bits, 1259 devpriv->write_byte(devpriv->command1_bits,
1260 dev->iobase + COMMAND1_REG); 1260 dev->iobase + COMMAND1_REG);
1261 } 1261 }
1262 /* setup any external triggering/pacing (command4 register) */
1263 devpriv->command4_bits = 0;
1264 if (cmd->convert_src != TRIG_EXT)
1265 devpriv->command4_bits |= EXT_CONVERT_DISABLE_BIT;
1266 /* XXX should discard first scan when using interval scanning
1267 * since manual says it is not synced with scan clock */
1268 if (labpc_use_continuous_mode(cmd) == 0) {
1269 devpriv->command4_bits |= INTERVAL_SCAN_EN_BIT;
1270 if (cmd->scan_begin_src == TRIG_EXT)
1271 devpriv->command4_bits |= EXT_SCAN_EN_BIT;
1272 }
1273 /* single-ended/differential */
1274 if (aref == AREF_DIFF)
1275 devpriv->command4_bits |= ADC_DIFF_BIT;
1276 devpriv->write_byte(devpriv->command4_bits, dev->iobase + COMMAND4_REG);
1277 1262
1278 devpriv->write_byte(cmd->chanlist_len, 1263 devpriv->write_byte(cmd->chanlist_len,
1279 dev->iobase + INTERVAL_COUNT_REG); 1264 dev->iobase + INTERVAL_COUNT_REG);
@@ -1351,6 +1336,22 @@ static int labpc_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
1351 devpriv->command3_bits &= ~ADC_FNE_INTR_EN_BIT; 1336 devpriv->command3_bits &= ~ADC_FNE_INTR_EN_BIT;
1352 devpriv->write_byte(devpriv->command3_bits, dev->iobase + COMMAND3_REG); 1337 devpriv->write_byte(devpriv->command3_bits, dev->iobase + COMMAND3_REG);
1353 1338
1339 /* setup any external triggering/pacing (command4 register) */
1340 devpriv->command4_bits = 0;
1341 if (cmd->convert_src != TRIG_EXT)
1342 devpriv->command4_bits |= EXT_CONVERT_DISABLE_BIT;
1343 /* XXX should discard first scan when using interval scanning
1344 * since manual says it is not synced with scan clock */
1345 if (labpc_use_continuous_mode(cmd) == 0) {
1346 devpriv->command4_bits |= INTERVAL_SCAN_EN_BIT;
1347 if (cmd->scan_begin_src == TRIG_EXT)
1348 devpriv->command4_bits |= EXT_SCAN_EN_BIT;
1349 }
1350 /* single-ended/differential */
1351 if (aref == AREF_DIFF)
1352 devpriv->command4_bits |= ADC_DIFF_BIT;
1353 devpriv->write_byte(devpriv->command4_bits, dev->iobase + COMMAND4_REG);
1354
1354 /* startup acquisition */ 1355 /* startup acquisition */
1355 1356
1356 /* command2 reg */ 1357 /* command2 reg */