]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/commitdiff
staging: comedi: cb_das16_cs: fix ai mux register programming
authorH Hartley Sweeten <hsweeten@visionengravers.com>
Mon, 12 Oct 2015 23:07:04 +0000 (16:07 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 13 Oct 2015 17:26:19 +0000 (10:26 -0700)
The ai mux register is used program the hi/lo channels in a scan.
According to the user manual, the hi and lo channels should be
the same  to sample one channel.

Introduce some macros to set the appropriate bits in the ai mux
register and fix the ai (*insn_read).

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>
drivers/staging/comedi/drivers/cb_das16_cs.c

index ac77b86d07af36e34af74a7ca8e334b03d2f7cac..15d03a74fcd0b5cb05582d48846547325723e37a 100644 (file)
  */
 #define DAS16CS_AI_DATA_REG            0x00
 #define DAS16CS_AI_MUX_REG             0x02
+#define DAS16CS_AI_MUX_HI_CHAN(x)      (((x) & 0xf) << 4)
+#define DAS16CS_AI_MUX_LO_CHAN(x)      (((x) & 0xf) << 0)
+#define DAS16CS_AI_MUX_SINGLE_CHAN(x)  (DAS16CS_AI_MUX_HI_CHAN(x) |    \
+                                        DAS16CS_AI_MUX_LO_CHAN(x))
 #define DAS16CS_MISC1_REG              0x04
 #define DAS16CS_MISC2_REG              0x06
 #define DAS16CS_TIMER_BASE             0x08
@@ -111,7 +115,8 @@ static int das16cs_ai_rinsn(struct comedi_device *dev,
        int ret;
        int i;
 
-       outw(chan, dev->iobase + DAS16CS_AI_MUX_REG);
+       outw(DAS16CS_AI_MUX_SINGLE_CHAN(chan),
+            dev->iobase + DAS16CS_AI_MUX_REG);
 
        devpriv->status1 &= ~0xf320;
        devpriv->status1 |= (aref == AREF_DIFF) ? 0 : 0x0020;