]> git.karo-electronics.de Git - linux-beck.git/commitdiff
staging: comedi: cb_pcimdas: use comedi_subdevice 'readback'
authorH Hartley Sweeten <hsweeten@visionengravers.com>
Mon, 25 Aug 2014 23:04:47 +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/cb_pcimdas.c

index 18e1801698ee4810a56c58e3fffd26953df06602..1bbe769c30b546a83029dd4fed1db8eeb009cad3 100644 (file)
@@ -79,9 +79,6 @@ struct cb_pcimdas_private {
        /* base addresses */
        unsigned long daqio;
        unsigned long BADR3;
-
-       /* Used for AO readback */
-       unsigned int ao_readback[2];
 };
 
 static int cb_pcimdas_ai_eoc(struct comedi_device *dev,
@@ -166,7 +163,7 @@ static int cb_pcimdas_ao_insn_write(struct comedi_device *dev,
 {
        struct cb_pcimdas_private *devpriv = dev->private;
        unsigned int chan = CR_CHAN(insn->chanspec);
-       unsigned int val = devpriv->ao_readback[chan];
+       unsigned int val = s->readback[chan];
        unsigned int reg = (chan) ? DAC1_OFFSET : DAC0_OFFSET;
        int i;
 
@@ -174,27 +171,11 @@ static int cb_pcimdas_ao_insn_write(struct comedi_device *dev,
                val = data[i];
                outw(val, devpriv->daqio + reg);
        }
-       devpriv->ao_readback[chan] = val;
+       s->readback[chan] = val;
 
        return insn->n;
 }
 
-/* AO subdevices should have a read insn as well as a write insn.
- * Usually this means copying a value stored in devpriv. */
-static int cb_pcimdas_ao_rinsn(struct comedi_device *dev,
-                              struct comedi_subdevice *s,
-                              struct comedi_insn *insn, unsigned int *data)
-{
-       struct cb_pcimdas_private *devpriv = dev->private;
-       int i;
-       int chan = CR_CHAN(insn->chanspec);
-
-       for (i = 0; i < insn->n; i++)
-               data[i] = devpriv->ao_readback[chan];
-
-       return i;
-}
-
 static int cb_pcimdas_auto_attach(struct comedi_device *dev,
                                            unsigned long context_unused)
 {
@@ -240,7 +221,11 @@ static int cb_pcimdas_auto_attach(struct comedi_device *dev,
        /* ranges are hardware settable, but not software readable. */
        s->range_table = &range_unknown;
        s->insn_write = cb_pcimdas_ao_insn_write;
-       s->insn_read = &cb_pcimdas_ao_rinsn;
+       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 */