Commit b1d6bffb authored by H Hartley Sweeten's avatar H Hartley Sweeten Committed by Greg Kroah-Hartman

staging: comedi: addi_apci_3501: 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: default avatarH Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: default avatarIan Abbott <abbotti@mev.co.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent b33bad98
...@@ -104,9 +104,9 @@ static int apci3501_ao_insn_write(struct comedi_device *dev, ...@@ -104,9 +104,9 @@ static int apci3501_ao_insn_write(struct comedi_device *dev,
{ {
unsigned int chan = CR_CHAN(insn->chanspec); unsigned int chan = CR_CHAN(insn->chanspec);
unsigned int range = CR_RANGE(insn->chanspec); unsigned int range = CR_RANGE(insn->chanspec);
unsigned int val = 0; unsigned int cfg = APCI3501_AO_DATA_CHAN(chan);
int i;
int ret; int ret;
int i;
/* /*
* All analog output channels have the same output range. * All analog output channels have the same output range.
...@@ -117,14 +117,14 @@ static int apci3501_ao_insn_write(struct comedi_device *dev, ...@@ -117,14 +117,14 @@ static int apci3501_ao_insn_write(struct comedi_device *dev,
if (range) { if (range) {
outl(0, dev->iobase + APCI3501_AO_CTRL_STATUS_REG); outl(0, dev->iobase + APCI3501_AO_CTRL_STATUS_REG);
} else { } else {
val |= APCI3501_AO_DATA_BIPOLAR; cfg |= APCI3501_AO_DATA_BIPOLAR;
outl(APCI3501_AO_CTRL_BIPOLAR, outl(APCI3501_AO_CTRL_BIPOLAR,
dev->iobase + APCI3501_AO_CTRL_STATUS_REG); dev->iobase + APCI3501_AO_CTRL_STATUS_REG);
} }
val |= APCI3501_AO_DATA_CHAN(chan);
for (i = 0; i < insn->n; i++) { for (i = 0; i < insn->n; i++) {
unsigned int val = data[i];
if (range == 1) { if (range == 1) {
if (data[i] > 0x1fff) { if (data[i] > 0x1fff) {
dev_err(dev->class_dev, dev_err(dev->class_dev,
...@@ -137,8 +137,10 @@ static int apci3501_ao_insn_write(struct comedi_device *dev, ...@@ -137,8 +137,10 @@ static int apci3501_ao_insn_write(struct comedi_device *dev,
if (ret) if (ret)
return ret; return ret;
outl(val | APCI3501_AO_DATA_VAL(data[i]), outl(cfg | APCI3501_AO_DATA_VAL(val),
dev->iobase + APCI3501_AO_DATA_REG); dev->iobase + APCI3501_AO_DATA_REG);
s->readback[chan] = val;
} }
return insn->n; return insn->n;
...@@ -360,6 +362,11 @@ static int apci3501_auto_attach(struct comedi_device *dev, ...@@ -360,6 +362,11 @@ static int apci3501_auto_attach(struct comedi_device *dev,
s->maxdata = 0x3fff; s->maxdata = 0x3fff;
s->range_table = &apci3501_ao_range; s->range_table = &apci3501_ao_range;
s->insn_write = apci3501_ao_insn_write; s->insn_write = apci3501_ao_insn_write;
s->insn_read = comedi_readback_insn_read;
ret = comedi_alloc_subdev_readback(s);
if (ret)
return ret;
} else { } else {
s->type = COMEDI_SUBD_UNUSED; s->type = COMEDI_SUBD_UNUSED;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment