From e8928754217560c70b1921de1a882cba9a069533 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 25 Aug 2014 16:04:27 -0700 Subject: [PATCH] staging: comedi: ni_atmio16d: 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 --- drivers/staging/comedi/drivers/ni_atmio16d.c | 23 ++++++-------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_atmio16d.c b/drivers/staging/comedi/drivers/ni_atmio16d.c index ed271ca4d9ec..2b730794b918 100644 --- a/drivers/staging/comedi/drivers/ni_atmio16d.c +++ b/drivers/staging/comedi/drivers/ni_atmio16d.c @@ -138,7 +138,6 @@ struct atmio16d_private { enum { dac_internal, dac_external } dac0_reference, dac1_reference; enum { dac_2comp, dac_straight } dac0_coding, dac1_coding; const struct comedi_lrange *ao_range_type_list[2]; - unsigned int ao_readback[2]; unsigned int com_reg_1_state; /* current state of command register 1 */ unsigned int com_reg_2_state; /* current state of command register 2 */ }; @@ -496,18 +495,6 @@ static int atmio16d_ai_insn_read(struct comedi_device *dev, return i; } -static int atmio16d_ao_insn_read(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) -{ - struct atmio16d_private *devpriv = dev->private; - int i; - - for (i = 0; i < insn->n; i++) - data[i] = devpriv->ao_readback[CR_CHAN(insn->chanspec)]; - return i; -} - static int atmio16d_ao_insn_write(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, @@ -527,7 +514,7 @@ static int atmio16d_ao_insn_write(struct comedi_device *dev, for (i = 0; i < insn->n; i++) { unsigned int val = data[i]; - devpriv->ao_readback[chan] = val; + s->readback[chan] = val; if (munge) val ^= 0x800; @@ -686,8 +673,6 @@ static int atmio16d_attach(struct comedi_device *dev, s->type = COMEDI_SUBD_AO; s->subdev_flags = SDF_WRITABLE; s->n_chan = 2; - s->insn_read = atmio16d_ao_insn_read; - s->insn_write = atmio16d_ao_insn_write; s->maxdata = 0xfff; /* 4095 decimal */ s->range_table_list = devpriv->ao_range_type_list; switch (devpriv->dac0_range) { @@ -706,6 +691,12 @@ static int atmio16d_attach(struct comedi_device *dev, devpriv->ao_range_type_list[1] = &range_unipolar10; break; } + s->insn_write = atmio16d_ao_insn_write; + s->insn_read = comedi_readback_insn_read; + + ret = comedi_alloc_subdev_readback(s); + if (ret) + return ret; /* Digital I/O */ s = &dev->subdevices[2]; -- 2.39.5