staging: comedi: ni_mio_common: use comedi_subdevice 'readback'
authorH Hartley Sweeten <hsweeten@visionengravers.com>
Mon, 25 Aug 2014 23:04:15 +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/ni_mio_common.c
drivers/staging/comedi/drivers/ni_stc.h

index c4c82d0178f16bf6feaf9f002ea1e6ef5e577959..237e3f8f93405f14bc0257ac377282722736a7a6 100644 (file)
@@ -2918,21 +2918,6 @@ static int ni_ao_config_chanlist(struct comedi_device *dev,
                return ni_old_ao_config_chanlist(dev, s, chanspec, n_chans);
 }
 
-static int ni_ao_insn_read(struct comedi_device *dev,
-                          struct comedi_subdevice *s,
-                          struct comedi_insn *insn,
-                          unsigned int *data)
-{
-       struct ni_private *devpriv = dev->private;
-       unsigned int chan = CR_CHAN(insn->chanspec);
-       int i;
-
-       for (i = 0; i < insn->n; i++)
-               data[i] = devpriv->ao[chan];
-
-       return insn->n;
-}
-
 static int ni_ao_insn_write(struct comedi_device *dev,
                            struct comedi_subdevice *s,
                            struct comedi_insn *insn,
@@ -2959,7 +2944,7 @@ static int ni_ao_insn_write(struct comedi_device *dev,
        for (i = 0; i < insn->n; i++) {
                unsigned int val = data[i];
 
-               devpriv->ao[chan] = val;
+               s->readback[chan] = val;
 
                if (devpriv->is_6xxx) {
                        /*
@@ -5485,9 +5470,13 @@ static int ni_E_init(struct comedi_device *dev,
                s->n_chan       = board->n_aochan;
                s->maxdata      = board->ao_maxdata;
                s->range_table  = board->ao_range_table;
-               s->insn_read    = ni_ao_insn_read;
-               s->insn_write   = ni_ao_insn_write;
                s->insn_config  = ni_ao_insn_config;
+               s->insn_write   = ni_ao_insn_write;
+               s->insn_read    = comedi_readback_insn_read;
+
+               ret = comedi_alloc_subdev_readback(s);
+               if (ret)
+                       return ret;
 
                /*
                 * Along with the IRQ we need either a FIFO or DMA for
index a2841292ddd49fdd6ed799e07eb626a813d7e117..29efce30eb7f0a25f0a70d11f21a94774539d355 100644 (file)
@@ -1423,7 +1423,6 @@ struct ni_private {
        unsigned int changain_spec;
 
        unsigned int caldac_maxdata_list[MAX_N_CALDACS];
-       unsigned short ao[MAX_N_AO_CHAN];
        unsigned short caldacs[MAX_N_CALDACS];
 
        unsigned short ai_cmd2;