This is a note to let you know that I've just added the patch titled

    staging: comedi: ni_labpc: correct differential channel sequence for

to my staging git tree which can be found at
    git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git
in the staging-next branch.

The patch will show up in the next release of the linux-next tree
(usually sometime within the next 24 hours during the week.)

The patch will also be merged in the next major kernel release
during the merge window.

If you have any questions about this process, please let me know.


>From 4c4bc25d0fa6beaf054c0b4c3b324487f266c820 Mon Sep 17 00:00:00 2001
From: Ian Abbott <[email protected]>
Date: Fri, 1 Feb 2013 14:51:58 +0000
Subject: staging: comedi: ni_labpc: correct differential channel sequence for
 AI commands

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 the setting of the channel bits for particular scanning modes
was incorrect for differential mode.  (Only half the number of channels
are available in differential mode; comedi refers to them as channels 0,
1, 2 and 3, but the hardware documentation refers to them as channels 0,
2, 4 and 6.)  In differential mode, the setting of the channel enable
bits in the command1 register should depend on whether the scan enable
bit is set.  Effectively, we need to double the comedi channel number
when the scan enable bit is not set in differential mode.  The scan
enable bit gets set when the AI scan mode is `MODE_MULT_CHAN_UP` or
`MODE_MULT_CHAN_DOWN`, and gets cleared when the AI scan mode is
`MODE_SINGLE_CHAN` or `MODE_SINGLE_CHAN_INTERVAL`.  The existing test
for whether the comedi channel number needs to be doubled in
differential mode is incorrect in `labpc_ai_cmd()`.  This patch corrects
the test.

Thanks to Tuomas for suggesting the fix.

Signed-off-by: Ian Abbott <[email protected]>
Cc: <[email protected]> # 3.7.x, 3.8.x
Signed-off-by: Greg Kroah-Hartman <[email protected]>
---
 drivers/staging/comedi/drivers/ni_labpc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/comedi/drivers/ni_labpc.c 
b/drivers/staging/comedi/drivers/ni_labpc.c
index 10bd2b3..f851c54 100644
--- a/drivers/staging/comedi/drivers/ni_labpc.c
+++ b/drivers/staging/comedi/drivers/ni_labpc.c
@@ -1204,7 +1204,8 @@ static int labpc_ai_cmd(struct comedi_device *dev, struct 
comedi_subdevice *s)
        else
                channel = CR_CHAN(cmd->chanlist[0]);
        /* munge channel bits for differential / scan disabled mode */
-       if (mode != MODE_SINGLE_CHAN && aref == AREF_DIFF)
+       if ((mode == MODE_SINGLE_CHAN || mode == MODE_SINGLE_CHAN_INTERVAL) &&
+           aref == AREF_DIFF)
                channel *= 2;
        devpriv->command1_bits |= ADC_CHAN_BITS(channel);
        devpriv->command1_bits |= thisboard->ai_range_code[range];
-- 
1.8.1.2.434.g9a6c84e.dirty


--
To unsubscribe from this list: send the line "unsubscribe stable" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to