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

index 7df8bb50d525844ed88364b4617b0101890247f7..092e2b17a5d3e3f51c360f877196ab435dd039ba 100644 (file)
@@ -83,7 +83,6 @@ static const struct ni_670x_board ni_670x_boards[] = {
 struct ni_670x_private {
        int boardtype;
        int dio;
-       unsigned int ao_readback[32];
 };
 
 static int ni_670x_ao_insn_write(struct comedi_device *dev,
@@ -91,9 +90,8 @@ static int ni_670x_ao_insn_write(struct comedi_device *dev,
                                 struct comedi_insn *insn,
                                 unsigned int *data)
 {
-       struct ni_670x_private *devpriv = dev->private;
        unsigned int chan = CR_CHAN(insn->chanspec);
-       unsigned int val = devpriv->ao_readback[chan];
+       unsigned int val = s->readback[chan];
        int i;
 
        /*
@@ -114,25 +112,11 @@ static int ni_670x_ao_insn_write(struct comedi_device *dev,
                /* write channel value */
                writel(val, dev->mmio + AO_VALUE_OFFSET);
        }
-       devpriv->ao_readback[chan] = val;
+       s->readback[chan] = val;
 
        return insn->n;
 }
 
-static int ni_670x_ao_rinsn(struct comedi_device *dev,
-                           struct comedi_subdevice *s,
-                           struct comedi_insn *insn, unsigned int *data)
-{
-       struct ni_670x_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 ni_670x_dio_insn_bits(struct comedi_device *dev,
                                 struct comedi_subdevice *s,
                                 struct comedi_insn *insn,
@@ -244,7 +228,11 @@ static int ni_670x_auto_attach(struct comedi_device *dev,
                s->range_table = &range_bipolar10;
        }
        s->insn_write = ni_670x_ao_insn_write;
-       s->insn_read = &ni_670x_ao_rinsn;
+       s->insn_read = comedi_readback_insn_read;
+
+       ret = comedi_alloc_subdev_readback(s);
+       if (ret)
+               return ret;
 
        s = &dev->subdevices[1];
        /* digital i/o subdevice */