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

staging: comedi: das6402: 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 58d10f32
......@@ -143,7 +143,6 @@ struct das6402_private {
unsigned int divider2;
unsigned int ao_range;
unsigned int ao_readback[2];
};
static void das6402_set_mode(struct comedi_device *dev,
......@@ -328,7 +327,7 @@ static int das6402_ao_insn_write(struct comedi_device *dev,
for (i = 0; i < insn->n; i++) {
val = data[i];
devpriv->ao_readback[chan] = val;
s->readback[chan] = val;
if (s->maxdata == 0x0fff) {
/*
......@@ -358,9 +357,7 @@ static int das6402_ao_insn_read(struct comedi_device *dev,
struct comedi_insn *insn,
unsigned int *data)
{
struct das6402_private *devpriv = dev->private;
unsigned int chan = CR_CHAN(insn->chanspec);
int i;
/*
* If XFER mode is enabled, reading any DAC register
......@@ -368,10 +365,7 @@ static int das6402_ao_insn_read(struct comedi_device *dev,
*/
inw(dev->iobase + DAS6402_AO_LSB_REG(chan));
for (i = 0; i < insn->n; i++)
data[i] = devpriv->ao_readback[chan];
return insn->n;
return comedi_readback_insn_read(dev, s, insn, data);
}
static int das6402_di_insn_bits(struct comedi_device *dev,
......@@ -510,6 +504,10 @@ static int das6402_attach(struct comedi_device *dev,
s->insn_write = das6402_ao_insn_write;
s->insn_read = das6402_ao_insn_read;
ret = comedi_alloc_subdev_readback(s);
if (ret)
return ret;
/* Digital Input subdevice */
s = &dev->subdevices[2];
s->type = COMEDI_SUBD_DI;
......
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