Mask off bogus high bits for m-series boards with 16 bits or less.
authorFrank Mori Hess <fmhess@speakeasy.net>
Tue, 10 Oct 2006 00:35:28 +0000 (00:35 +0000)
committerFrank Mori Hess <fmhess@speakeasy.net>
Tue, 10 Oct 2006 00:35:28 +0000 (00:35 +0000)
comedi/drivers/ni_mio_common.c

index 4f7456f8f7b74353ba928e9d98aa9b44cf758b85..46348590e5b117c1d2f57af8190123a8b6cb3b5f 100644 (file)
@@ -1305,7 +1305,7 @@ static int ni_ai_poll(comedi_device *dev,comedi_subdevice *s)
 static int ni_ai_insn_read(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data)
 {
        int i,n;
-       unsigned int mask;
+       const unsigned int mask = (1 << boardtype.adbits) - 1;
        unsigned signbits;
        unsigned short d;
        unsigned long dl;
@@ -1314,7 +1314,6 @@ static int ni_ai_insn_read(comedi_device *dev,comedi_subdevice *s,comedi_insn *i
 
        ni_flush_ai_fifo(dev);
 
-       mask=(1<<boardtype.adbits)-1;
        signbits=devpriv->ai_offset[0];
        if(boardtype.reg_type == ni_reg_611x){
                for(n=0; n < num_adc_stages_611x; n++){
@@ -1377,8 +1376,7 @@ static int ni_ai_insn_read(comedi_device *dev,comedi_subdevice *s,comedi_insn *i
                        }
                        if(boardtype.reg_type == ni_reg_m_series)
                        {
-                               data[n] = ni_readl(M_Offset_AI_FIFO_Data);
-                               data[n] += signbits;
+                               data[n] = ni_readl(M_Offset_AI_FIFO_Data) & mask;
                        }else
                        {
                                d = ni_readw(ADC_FIFO_Data_Register);