From 15aba0d23987ee921737deb23663a0eb0c6b5697 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 25 Aug 2014 16:04:41 -0700 Subject: [PATCH] staging: comedi: daqboard2000: 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. For aesthetics, tidy up the (*insn_write) a bit. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/daqboard2000.c | 35 +++++++------------ 1 file changed, 12 insertions(+), 23 deletions(-) diff --git a/drivers/staging/comedi/drivers/daqboard2000.c b/drivers/staging/comedi/drivers/daqboard2000.c index 266c434ccf39..dc299f6fa611 100644 --- a/drivers/staging/comedi/drivers/daqboard2000.c +++ b/drivers/staging/comedi/drivers/daqboard2000.c @@ -275,7 +275,6 @@ struct daqboard2000_private { card_daqboard_2000 } card; void __iomem *plx; - unsigned int ao_readback[2]; }; static void writeAcqScanListEntry(struct comedi_device *dev, u16 entry) @@ -401,21 +400,6 @@ static int daqboard2000_ai_insn_read(struct comedi_device *dev, return i; } -static int daqboard2000_ao_insn_read(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) -{ - struct daqboard2000_private *devpriv = dev->private; - int chan = CR_CHAN(insn->chanspec); - int i; - - for (i = 0; i < insn->n; i++) - data[i] = devpriv->ao_readback[chan]; - - return i; -} - static int daqboard2000_ao_eoc(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, @@ -435,22 +419,23 @@ static int daqboard2000_ao_insn_write(struct comedi_device *dev, struct comedi_insn *insn, unsigned int *data) { - struct daqboard2000_private *devpriv = dev->private; - int chan = CR_CHAN(insn->chanspec); - int ret; + unsigned int chan = CR_CHAN(insn->chanspec); int i; for (i = 0; i < insn->n; i++) { - writew(data[i], dev->mmio + dacSetting(chan)); + unsigned int val = data[i]; + int ret; + + writew(val, dev->mmio + dacSetting(chan)); ret = comedi_timeout(dev, s, insn, daqboard2000_ao_eoc, 0); if (ret) return ret; - devpriv->ao_readback[chan] = data[i]; + s->readback[chan] = val; } - return i; + return insn->n; } static void daqboard2000_resetLocalBus(struct comedi_device *dev) @@ -721,10 +706,14 @@ static int daqboard2000_auto_attach(struct comedi_device *dev, s->subdev_flags = SDF_WRITABLE; s->n_chan = 2; s->maxdata = 0xffff; - s->insn_read = daqboard2000_ao_insn_read; s->insn_write = daqboard2000_ao_insn_write; + s->insn_read = comedi_readback_insn_read; s->range_table = &range_bipolar10; + result = comedi_alloc_subdev_readback(s); + if (result) + return result; + s = &dev->subdevices[2]; result = subdev_8255_init(dev, s, daqboard2000_8255_cb, dioP2ExpansionIO8Bit); -- 2.34.1