staging: comedi: das6402: use comedi_subdevice 'readback'
authorH Hartley Sweeten <hsweeten@visionengravers.com>
Mon, 25 Aug 2014 23:04:18 +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/das6402.c

index d18eea6..7d9f26a 100644 (file)
@@ -143,7 +143,6 @@ struct das6402_private {
        unsigned int divider2;
 
        unsigned int ao_range;
-       unsigned int ao_readback[2];
 };
 
 static void das6402_set_mode(struct comedi_device *dev,
@@ -328,7 +327,7 @@ static int das6402_ao_insn_write(struct comedi_device *dev,
        for (i = 0; i < insn->n; i++) {
                val = data[i];
 
-               devpriv->ao_readback[chan] = val;
+               s->readback[chan] = val;
 
                if (s->maxdata == 0x0fff) {
                        /*
@@ -358,9 +357,7 @@ static int das6402_ao_insn_read(struct comedi_device *dev,
                                struct comedi_insn *insn,
                                unsigned int *data)
 {
-       struct das6402_private *devpriv = dev->private;
        unsigned int chan = CR_CHAN(insn->chanspec);
-       int i;
 
        /*
         * If XFER mode is enabled, reading any DAC register
@@ -368,10 +365,7 @@ static int das6402_ao_insn_read(struct comedi_device *dev,
         */
        inw(dev->iobase + DAS6402_AO_LSB_REG(chan));
 
-       for (i = 0; i < insn->n; i++)
-               data[i] = devpriv->ao_readback[chan];
-
-       return insn->n;
+       return comedi_readback_insn_read(dev, s, insn, data);
 }
 
 static int das6402_di_insn_bits(struct comedi_device *dev,
@@ -510,6 +504,10 @@ static int das6402_attach(struct comedi_device *dev,
        s->insn_write   = das6402_ao_insn_write;
        s->insn_read    = das6402_ao_insn_read;
 
+       ret = comedi_alloc_subdev_readback(s);
+       if (ret)
+               return ret;
+
        /* Digital Input subdevice */
        s = &dev->subdevices[2];
        s->type         = COMEDI_SUBD_DI;