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

index d20b508065831fe61a5c5389614c3b228ab6afb1..3e812f0e32c1e0e47e0f50d2c2b3e45bbeaac701 100644 (file)
@@ -176,8 +176,6 @@ broken.
 struct me4000_info {
        unsigned long plx_regbase;
        unsigned long timer_regbase;
-
-       unsigned int ao_readback[4];
 };
 
 enum me4000_boardid {
@@ -1193,7 +1191,6 @@ static int me4000_ao_insn_write(struct comedi_device *dev,
                                struct comedi_insn *insn,
                                unsigned int *data)
 {
-       struct me4000_info *info = dev->private;
        int chan = CR_CHAN(insn->chanspec);
        unsigned int tmp;
 
@@ -1209,26 +1206,7 @@ static int me4000_ao_insn_write(struct comedi_device *dev,
        outl(data[0], dev->iobase + ME4000_AO_SINGLE_REG(chan));
 
        /* Store in the mirror */
-       info->ao_readback[chan] = data[0];
-
-       return 1;
-}
-
-static int me4000_ao_insn_read(struct comedi_device *dev,
-                              struct comedi_subdevice *s,
-                              struct comedi_insn *insn, unsigned int *data)
-{
-       struct me4000_info *info = dev->private;
-       int chan = CR_CHAN(insn->chanspec);
-
-       if (insn->n == 0) {
-               return 0;
-       } else if (insn->n > 1) {
-               dev_err(dev->class_dev, "Invalid instruction length\n");
-               return -EINVAL;
-       }
-
-       data[0] = info->ao_readback[chan];
+       s->readback[chan] = data[0];
 
        return 1;
 }
@@ -1478,7 +1456,11 @@ static int me4000_auto_attach(struct comedi_device *dev,
                s->maxdata = 0xFFFF;    /*  16 bit DAC */
                s->range_table = &range_bipolar10;
                s->insn_write = me4000_ao_insn_write;
-               s->insn_read = me4000_ao_insn_read;
+               s->insn_read = comedi_readback_insn_read;
+
+               result = comedi_alloc_subdev_readback(s);
+               if (result)
+                       return result;
        } else {
                s->type = COMEDI_SUBD_UNUSED;
        }