From 42c7b55cce1c52e9d3f605243e9d389fa6c9213b Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 25 Aug 2014 16:04:29 -0700 Subject: [PATCH] staging: comedi: me_daq: 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/me_daq.c | 26 +++++++------------------ 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/drivers/staging/comedi/drivers/me_daq.c b/drivers/staging/comedi/drivers/me_daq.c index df1fceb3c53f..9ff9af6d4262 100644 --- a/drivers/staging/comedi/drivers/me_daq.c +++ b/drivers/staging/comedi/drivers/me_daq.c @@ -171,7 +171,6 @@ struct me_private_data { unsigned short control_1; /* Mirror of CONTROL_1 register */ unsigned short control_2; /* Mirror of CONTROL_2 register */ unsigned short dac_control; /* Mirror of the DAC_CONTROL register */ - int ao_readback[4]; /* Mirror of analog output data */ }; static inline void sleep(unsigned sec) @@ -325,7 +324,7 @@ static int me_ao_insn_write(struct comedi_device *dev, struct me_private_data *dev_private = dev->private; unsigned int chan = CR_CHAN(insn->chanspec); unsigned int rang = CR_RANGE(insn->chanspec); - unsigned int val = dev_private->ao_readback[chan]; + unsigned int val = s->readback[chan]; int i; /* Enable all DAC */ @@ -358,7 +357,7 @@ static int me_ao_insn_write(struct comedi_device *dev, writew(val, dev->mmio + ME_DAC_DATA_A + (chan << 1)); } - dev_private->ao_readback[chan] = val; + s->readback[chan] = val; /* Update dac with data registers */ readw(dev->mmio + ME_DAC_UPDATE); @@ -366,21 +365,6 @@ static int me_ao_insn_write(struct comedi_device *dev, return insn->n; } -static int me_ao_insn_read(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) -{ - struct me_private_data *dev_private = dev->private; - unsigned int chan = CR_CHAN(insn->chanspec); - int i; - - for (i = 0; i < insn->n; i++) - data[i] = dev_private->ao_readback[chan]; - - return insn->n; -} - static int me2600_xilinx_download(struct comedi_device *dev, const u8 *data, size_t size, unsigned long context) @@ -532,8 +516,12 @@ static int me_auto_attach(struct comedi_device *dev, s->maxdata = 0x0fff; s->len_chanlist = 4; s->range_table = &me_ao_range; - s->insn_read = me_ao_insn_read; s->insn_write = me_ao_insn_write; + s->insn_read = comedi_readback_insn_read; + + ret = comedi_alloc_subdev_readback(s); + if (ret) + return ret; } else { s->type = COMEDI_SUBD_UNUSED; } -- 2.30.2