]> git.karo-electronics.de Git - linux-beck.git/commitdiff
staging: comedi: ni_labpc_common: use subdevice readback for analog outputs
authorH Hartley Sweeten <hsweeten@visionengravers.com>
Thu, 20 Nov 2014 22:07:34 +0000 (15:07 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 26 Nov 2014 23:39:17 +0000 (15:39 -0800)
Use the comedi_subdevice 'readback' member and the core provided (*insn_read)
to handle the readback of the analog output subdevice. Remove the then unused
'ao_value' member from the private data.

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_labpc.h
drivers/staging/comedi/drivers/ni_labpc_common.c

index 3261e226cc3daa2eb88bd7e801496c581589c2db..e6a95f94774c666049cd7c416a5866292c5df23f 100644 (file)
@@ -37,8 +37,6 @@ struct labpc_boardinfo {
 struct labpc_private {
        /*  number of data points left to be taken */
        unsigned long long count;
-       /*  software copy of analog output values */
-       unsigned int ao_value[NUM_AO_CHAN];
        /*  software copys of bits written to command registers */
        unsigned int cmd1;
        unsigned int cmd2;
index 354c33e6f21ccfa0da75624c0b646df8a40ebd2f..a6c63b511a66ee8f212aebbefaab9229dd744a77 100644 (file)
@@ -927,7 +927,7 @@ static void labpc_ao_write(struct comedi_device *dev,
        devpriv->write_byte(dev, val & 0xff, DAC_LSB_REG(chan));
        devpriv->write_byte(dev, (val >> 8) & 0xff, DAC_MSB_REG(chan));
 
-       devpriv->ao_value[chan] = val;
+       s->readback[chan] = val;
 }
 
 static int labpc_ao_insn_write(struct comedi_device *dev,
@@ -966,18 +966,6 @@ static int labpc_ao_insn_write(struct comedi_device *dev,
        return 1;
 }
 
-static int labpc_ao_insn_read(struct comedi_device *dev,
-                             struct comedi_subdevice *s,
-                             struct comedi_insn *insn,
-                             unsigned int *data)
-{
-       struct labpc_private *devpriv = dev->private;
-
-       data[0] = devpriv->ao_value[CR_CHAN(insn->chanspec)];
-
-       return 1;
-}
-
 /* lowlevel write to eeprom/dac */
 static void labpc_serial_out(struct comedi_device *dev, unsigned int value,
                             unsigned int value_width)
@@ -1301,9 +1289,12 @@ int labpc_common_attach(struct comedi_device *dev,
                s->n_chan       = NUM_AO_CHAN;
                s->maxdata      = 0x0fff;
                s->range_table  = &range_labpc_ao;
-               s->insn_read    = labpc_ao_insn_read;
                s->insn_write   = labpc_ao_insn_write;
 
+               ret = comedi_alloc_subdev_readback(s);
+               if (ret)
+                       return ret;
+
                /* initialize analog outputs to a known value */
                for (i = 0; i < s->n_chan; i++)
                        labpc_ao_write(dev, s, i, s->maxdata / 2);