From 800242553a3fbc42741c95e108655dc4081ac73c Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 25 Aug 2014 16:04:02 -0700 Subject: [PATCH] staging: comedi: adl_pci9111: 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/adl_pci9111.c | 28 ++++++-------------- 1 file changed, 8 insertions(+), 20 deletions(-) diff --git a/drivers/staging/comedi/drivers/adl_pci9111.c b/drivers/staging/comedi/drivers/adl_pci9111.c index 51edfebb952a..9ba367e27e93 100644 --- a/drivers/staging/comedi/drivers/adl_pci9111.c +++ b/drivers/staging/comedi/drivers/adl_pci9111.c @@ -139,8 +139,6 @@ struct pci9111_private_data { unsigned int chunk_counter; unsigned int chunk_num_samples; - int ao_readback; - unsigned int div1; unsigned int div2; @@ -643,29 +641,15 @@ static int pci9111_ao_insn_write(struct comedi_device *dev, struct comedi_insn *insn, unsigned int *data) { - struct pci9111_private_data *dev_private = dev->private; - unsigned int val = 0; + unsigned int chan = CR_CHAN(insn->chanspec); + unsigned int val = s->readback[chan]; int i; for (i = 0; i < insn->n; i++) { val = data[i]; outw(val, dev->iobase + PCI9111_AO_REG); } - dev_private->ao_readback = val; - - return insn->n; -} - -static int pci9111_ao_insn_read(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) -{ - struct pci9111_private_data *dev_private = dev->private; - int i; - - for (i = 0; i < insn->n; i++) - data[i] = dev_private->ao_readback; + s->readback[chan] = val; return insn->n; } @@ -768,7 +752,11 @@ static int pci9111_auto_attach(struct comedi_device *dev, s->len_chanlist = 1; s->range_table = &range_bipolar10; s->insn_write = pci9111_ao_insn_write; - s->insn_read = pci9111_ao_insn_read; + s->insn_read = comedi_readback_insn_read; + + ret = comedi_alloc_subdev_readback(s); + if (ret) + return ret; s = &dev->subdevices[2]; s->type = COMEDI_SUBD_DI; -- 2.30.2