]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/commitdiff
staging: comedi: ni_mio_common: merge analog output (*insn_write) functions
authorH Hartley Sweeten <hsweeten@visionengravers.com>
Mon, 14 Jul 2014 19:23:48 +0000 (12:23 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 16 Jul 2014 20:24:42 +0000 (13:24 -0700)
Currently the PCI6xxx boards use a different (*insn_write) function
for the analog output subdevice. Most of the code is identical to the
(*insn_write) used by all the other board types.

For aesthetics, merge the two (*insn_write) functions and handle the
'is_6xxx' differences in the common code.

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/ni_mio_common.c

index 6e79bcf3ce876d43576db0e323ac25e619323071..9bcf8351129d9fa9d23f28d1e09697b14636a957 100644 (file)
@@ -2964,10 +2964,15 @@ static int ni_ao_insn_write(struct comedi_device *dev,
        int reg;
        int i;
 
-       if (devpriv->is_m_series)
+       if (devpriv->is_6xxx) {
+               ni_ao_win_outw(dev, 1 << chan, AO_Immediate_671x);
+
+               reg = DACx_Direct_Data_671x(chan);
+       } else if (devpriv->is_m_series) {
                reg = M_Offset_DAC_Direct_Data(chan);
-       else
+       } else {
                reg = (chan) ? DAC1_Direct_Data : DAC0_Direct_Data;
+       }
 
        ni_ao_config_chanlist(dev, s, &insn->chanspec, 1, 0);
 
@@ -2976,8 +2981,19 @@ static int ni_ao_insn_write(struct comedi_device *dev,
 
                devpriv->ao[chan] = val;
 
-               if (devpriv->is_m_series) {
-                       /* M-series board always use offset binary values */
+               if (devpriv->is_6xxx) {
+                       /*
+                        * 6xxx boards have bipolar outputs, munge the
+                        * unsigned comedi values to 2's complement
+                        */
+                       val = comedi_offset_munge(s, val);
+
+                       ni_ao_win_outw(dev, val, reg);
+               } else if (devpriv->is_m_series) {
+                       /*
+                        * M-series boards use offset binary values for
+                        * bipolar and uinpolar outputs
+                        */
                        ni_writew(dev, val, reg);
                } else {
                        /*
@@ -2994,36 +3010,6 @@ static int ni_ao_insn_write(struct comedi_device *dev,
        return insn->n;
 }
 
-static int ni_ao_insn_write_671x(struct comedi_device *dev,
-                                struct comedi_subdevice *s,
-                                struct comedi_insn *insn,
-                                unsigned int *data)
-{
-       struct ni_private *devpriv = dev->private;
-       unsigned int chan = CR_CHAN(insn->chanspec);
-       int i;
-
-       ni_ao_win_outw(dev, 1 << chan, AO_Immediate_671x);
-
-       ni_ao_config_chanlist(dev, s, &insn->chanspec, 1, 0);
-
-       for (i = 0; i < insn->n; i++) {
-               unsigned int val = data[i];
-
-               devpriv->ao[chan] = val;
-
-               /*
-                * 671x boards have +/-10V outputs
-                * munge the unsigned comedi values to 2's complement
-                */
-               val = comedi_offset_munge(s, val);
-
-               ni_ao_win_outw(dev, val, DACx_Direct_Data_671x(chan));
-       }
-
-       return insn->n;
-}
-
 static int ni_ao_insn_config(struct comedi_device *dev,
                             struct comedi_subdevice *s,
                             struct comedi_insn *insn, unsigned int *data)
@@ -5565,10 +5551,7 @@ static int ni_E_init(struct comedi_device *dev,
                s->maxdata = (1 << board->aobits) - 1;
                s->range_table = board->ao_range_table;
                s->insn_read = &ni_ao_insn_read;
-               if (devpriv->is_6xxx)
-                       s->insn_write = &ni_ao_insn_write_671x;
-               else
-                       s->insn_write = &ni_ao_insn_write;
+               s->insn_write = &ni_ao_insn_write;
                s->insn_config = &ni_ao_insn_config;
 #ifdef PCIDMA
                if (board->n_aochan) {