From: H Hartley Sweeten Date: Mon, 25 Aug 2014 23:04:15 +0000 (-0700) Subject: staging: comedi: ni_mio_common: use comedi_subdevice 'readback' X-Git-Tag: firefly_0821_release~176^2~3121^2~1037 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=b6d977e9fb8c63435ba5dec87e707e088df7e7f8;p=firefly-linux-kernel-4.4.55.git staging: comedi: ni_mio_common: use comedi_subdevice 'readback' 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 Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index c4c82d0178f1..237e3f8f9340 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -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 diff --git a/drivers/staging/comedi/drivers/ni_stc.h b/drivers/staging/comedi/drivers/ni_stc.h index a2841292ddd4..29efce30eb7f 100644 --- a/drivers/staging/comedi/drivers/ni_stc.h +++ b/drivers/staging/comedi/drivers/ni_stc.h @@ -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;