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

index c16d468625ab2274e9c74604ba7453e99f95e667..d28d41c978d74ff65e58469d9e785c35ff709723 100644 (file)
@@ -207,9 +207,7 @@ static const struct dt2801_board boardtypes[] = {
 };
 
 struct dt2801_private {
-
        const struct comedi_lrange *dac_range_types[2];
-       unsigned int ao_readback[2];
 };
 
 /* These are the low-level routines:
@@ -463,28 +461,18 @@ static int dt2801_ai_insn_read(struct comedi_device *dev,
        return i;
 }
 
-static int dt2801_ao_insn_read(struct comedi_device *dev,
-                              struct comedi_subdevice *s,
-                              struct comedi_insn *insn, unsigned int *data)
-{
-       struct dt2801_private *devpriv = dev->private;
-
-       data[0] = devpriv->ao_readback[CR_CHAN(insn->chanspec)];
-
-       return 1;
-}
-
 static int dt2801_ao_insn_write(struct comedi_device *dev,
                                struct comedi_subdevice *s,
-                               struct comedi_insn *insn, unsigned int *data)
+                               struct comedi_insn *insn,
+                               unsigned int *data)
 {
-       struct dt2801_private *devpriv = dev->private;
+       unsigned int chan = CR_CHAN(insn->chanspec);
 
        dt2801_writecmd(dev, DT_C_WRITE_DAIM);
-       dt2801_writedata(dev, CR_CHAN(insn->chanspec));
+       dt2801_writedata(dev, chan);
        dt2801_writedata2(dev, data[0]);
 
-       devpriv->ao_readback[CR_CHAN(insn->chanspec)] = data[0];
+       s->readback[chan] = data[0];
 
        return 1;
 }
@@ -608,8 +596,12 @@ havetype:
        s->range_table_list = devpriv->dac_range_types;
        devpriv->dac_range_types[0] = dac_range_lkup(it->options[4]);
        devpriv->dac_range_types[1] = dac_range_lkup(it->options[5]);
-       s->insn_read = dt2801_ao_insn_read;
        s->insn_write = dt2801_ao_insn_write;
+       s->insn_read = comedi_readback_insn_read;
+
+       ret = comedi_alloc_subdev_readback(s);
+       if (ret)
+               return ret;
 
        s = &dev->subdevices[2];
        /* 1st digital subdevice */