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

index 1c7a135c91d68f74ee62292edaf50843236c2953..59108c06cedc3d007aec5b9a015fc26570cf7fca 100644 (file)
@@ -61,7 +61,6 @@ static const struct comedi_lrange pcmda12_ranges = {
 };
 
 struct pcmda12_private {
-       unsigned int ao_readback[8];
        int simultaneous_xfer_mode;
 };
 
@@ -72,7 +71,7 @@ static int pcmda12_ao_insn_write(struct comedi_device *dev,
 {
        struct pcmda12_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 long ioreg = dev->iobase + (chan * 2);
        int i;
 
@@ -88,7 +87,7 @@ static int pcmda12_ao_insn_write(struct comedi_device *dev,
                if (!devpriv->simultaneous_xfer_mode)
                        inb(ioreg);
        }
-       devpriv->ao_readback[chan] = val;
+       s->readback[chan] = val;
 
        return insn->n;
 }
@@ -99,8 +98,6 @@ static int pcmda12_ao_insn_read(struct comedi_device *dev,
                                unsigned int *data)
 {
        struct pcmda12_private *devpriv = dev->private;
-       unsigned int chan = CR_CHAN(insn->chanspec);
-       int i;
 
        /*
         * Initiate simultaneaous xfer mode by reading one of the
@@ -109,10 +106,7 @@ static int pcmda12_ao_insn_read(struct comedi_device *dev,
        if (devpriv->simultaneous_xfer_mode)
                inb(dev->iobase);
 
-       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 void pcmda12_ao_reset(struct comedi_device *dev,
@@ -158,6 +152,10 @@ static int pcmda12_attach(struct comedi_device *dev,
        s->insn_write   = pcmda12_ao_insn_write;
        s->insn_read    = pcmda12_ao_insn_read;
 
+       ret = comedi_alloc_subdev_readback(s);
+       if (ret)
+               return ret;
+
        pcmda12_ao_reset(dev, s);
 
        return 0;