]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commitdiff
staging: comedi: s626: use comedi_subdevice 'readback'
authorH Hartley Sweeten <hsweeten@visionengravers.com>
Mon, 25 Aug 2014 23:04:09 +0000 (16:04 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 30 Aug 2014 20:22:31 +0000 (13:22 -0700)
Use the new comedi_subdevice 'readback' member and the core provided
(*insn_read) for the readback of the analog output subdevice channels.

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

index e42720c9b774ab5b0dceacc3cd99a882bd7d4ad0..800121949ff4207a0bcef4651677da985257b5c3 100644 (file)
@@ -98,7 +98,6 @@ struct s626_private {
        uint8_t trim_setpoint[12];      /* images of TrimDAC setpoints */
        uint32_t i2c_adrs;              /* I2C device address for onboard EEPROM
                                         * (board rev dependent) */
-       unsigned int ao_readback[S626_DAC_CHANNELS];
 };
 
 /* Counter overflow/index event flag masks for RDMISC2. */
@@ -2268,38 +2267,28 @@ static int s626_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
        return 0;
 }
 
-static int s626_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
-                        struct comedi_insn *insn, unsigned int *data)
+static int s626_ao_insn_write(struct comedi_device *dev,
+                             struct comedi_subdevice *s,
+                             struct comedi_insn *insn,
+                             unsigned int *data)
 {
-       struct s626_private *devpriv = dev->private;
+       unsigned int chan = CR_CHAN(insn->chanspec);
        int i;
-       int ret;
-       uint16_t chan = CR_CHAN(insn->chanspec);
-       int16_t dacdata;
 
        for (i = 0; i < insn->n; i++) {
-               dacdata = (int16_t) data[i];
-               devpriv->ao_readback[CR_CHAN(insn->chanspec)] = data[i];
+               int16_t dacdata = (int16_t)data[i];
+               int ret;
+
                dacdata -= (0x1fff);
 
                ret = s626_set_dac(dev, chan, dacdata);
                if (ret)
                        return ret;
-       }
-
-       return i;
-}
-
-static int s626_ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
-                        struct comedi_insn *insn, unsigned int *data)
-{
-       struct s626_private *devpriv = dev->private;
-       int i;
 
-       for (i = 0; i < insn->n; i++)
-               data[i] = devpriv->ao_readback[CR_CHAN(insn->chanspec)];
+               s->readback[chan] = data[i];
+       }
 
-       return i;
+       return insn->n;
 }
 
 /* *************** DIGITAL I/O FUNCTIONS *************** */
@@ -2843,8 +2832,12 @@ static int s626_auto_attach(struct comedi_device *dev,
        s->n_chan       = S626_DAC_CHANNELS;
        s->maxdata      = 0x3fff;
        s->range_table  = &range_bipolar10;
-       s->insn_write   = s626_ao_winsn;
-       s->insn_read    = s626_ao_rinsn;
+       s->insn_write   = s626_ao_insn_write;
+       s->insn_read    = comedi_readback_insn_read;
+
+       ret = comedi_alloc_subdev_readback(s);
+       if (ret)
+               return ret;
 
        s = &dev->subdevices[2];
        /* digital I/O subdevice */