]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
staging: comedi: ni_670x: cleanup ni_670x_ao_winsn()
authorH Hartley Sweeten <hsweeten@visionengravers.com>
Mon, 25 Aug 2014 23:04:44 +0000 (16:04 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 30 Aug 2014 20:22:33 +0000 (13:22 -0700)
For aesthetics, rename this function and tidy it up a bit.

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_670x.c

index f5caefad0b5942cc45d66bcf244e46abe4216328..7df8bb50d525844ed88364b4617b0101890247f7 100644 (file)
@@ -86,35 +86,37 @@ struct ni_670x_private {
        unsigned int ao_readback[32];
 };
 
-static int ni_670x_ao_winsn(struct comedi_device *dev,
-                           struct comedi_subdevice *s,
-                           struct comedi_insn *insn, unsigned int *data)
+static int ni_670x_ao_insn_write(struct comedi_device *dev,
+                                struct comedi_subdevice *s,
+                                struct comedi_insn *insn,
+                                unsigned int *data)
 {
        struct ni_670x_private *devpriv = dev->private;
+       unsigned int chan = CR_CHAN(insn->chanspec);
+       unsigned int val = devpriv->ao_readback[chan];
        int i;
-       int chan = CR_CHAN(insn->chanspec);
-
-       /* Channel number mapping :
-
-          NI 6703/ NI 6704     | NI 6704 Only
-          ----------------------------------------------------
-          vch(0)       :       0       | ich(16)       :       1
-          vch(1)       :       2       | ich(17)       :       3
-          .    :       .       |   .                   .
-          .    :       .       |   .                   .
-          .    :       .       |   .                   .
-          vch(15)      :       30      | ich(31)       :       31      */
 
+       /*
+        * Channel number mapping:
+        *
+        * NI 6703/ NI 6704 | NI 6704 Only
+        * -------------------------------
+        * vch(0)  :  0     | ich(16) :  1
+        * vch(1)  :  2     | ich(17) :  3
+        * ...              | ...
+        * vch(15) : 30     | ich(31) : 31
+        */
        for (i = 0; i < insn->n; i++) {
+               val = data[i];
                /* First write in channel register which channel to use */
                writel(((chan & 15) << 1) | ((chan & 16) >> 4),
                       dev->mmio + AO_CHAN_OFFSET);
                /* write channel value */
-               writel(data[i], dev->mmio + AO_VALUE_OFFSET);
-               devpriv->ao_readback[chan] = data[i];
+               writel(val, dev->mmio + AO_VALUE_OFFSET);
        }
+       devpriv->ao_readback[chan] = val;
 
-       return i;
+       return insn->n;
 }
 
 static int ni_670x_ao_rinsn(struct comedi_device *dev,
@@ -241,7 +243,7 @@ static int ni_670x_auto_attach(struct comedi_device *dev,
        } else {
                s->range_table = &range_bipolar10;
        }
-       s->insn_write = &ni_670x_ao_winsn;
+       s->insn_write = ni_670x_ao_insn_write;
        s->insn_read = &ni_670x_ao_rinsn;
 
        s = &dev->subdevices[1];