staging: comedi: pcl726: use comedi_subdevice 'readback'
authorH Hartley Sweeten <hsweeten@visionengravers.com>
Mon, 25 Aug 2014 23:04:06 +0000 (16:04 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 30 Aug 2014 20:22:30 +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/pcl726.c

index 8cb5efde4943bc53a07afc12fe3cb57ee604bf26..855c37159d2593e26a104fc5ca46e6f3dcd4cc60 100644 (file)
@@ -156,7 +156,6 @@ static const struct pcl726_board pcl726_boards[] = {
 
 struct pcl726_private {
        const struct comedi_lrange *rangelist[12];
-       unsigned int ao_readback[12];
        unsigned int cmd_running:1;
 };
 
@@ -249,15 +248,14 @@ static int pcl726_ao_insn_write(struct comedi_device *dev,
                                struct comedi_insn *insn,
                                unsigned int *data)
 {
-       struct pcl726_private *devpriv = dev->private;
        unsigned int chan = CR_CHAN(insn->chanspec);
        unsigned int range = CR_RANGE(insn->chanspec);
-       unsigned int val;
        int i;
 
        for (i = 0; i < insn->n; i++) {
-               val = data[i];
-               devpriv->ao_readback[chan] = val;
+               unsigned int val = data[i];
+
+               s->readback[chan] = val;
 
                /* bipolar data to the DAC is two's complement */
                if (comedi_chan_range_is_bipolar(s, chan, range))
@@ -271,21 +269,6 @@ static int pcl726_ao_insn_write(struct comedi_device *dev,
        return insn->n;
 }
 
-static int pcl726_ao_insn_read(struct comedi_device *dev,
-                              struct comedi_subdevice *s,
-                              struct comedi_insn *insn,
-                              unsigned int *data)
-{
-       struct pcl726_private *devpriv = dev->private;
-       unsigned int chan = CR_CHAN(insn->chanspec);
-       int i;
-
-       for (i = 0; i < insn->n; i++)
-               data[i] = devpriv->ao_readback[chan];
-
-       return insn->n;
-}
-
 static int pcl726_di_insn_bits(struct comedi_device *dev,
                               struct comedi_subdevice *s,
                               struct comedi_insn *insn,
@@ -394,7 +377,11 @@ static int pcl726_attach(struct comedi_device *dev,
        s->maxdata      = 0x0fff;
        s->range_table_list = devpriv->rangelist;
        s->insn_write   = pcl726_ao_insn_write;
-       s->insn_read    = pcl726_ao_insn_read;
+       s->insn_read    = comedi_readback_insn_read;
+
+       ret = comedi_alloc_subdev_readback(s);
+       if (ret)
+               return ret;
 
        if (board->have_dio) {
                /* Digital Input subdevice */