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

staging: comedi: ni_at_ao: 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 096b4b0a
...@@ -118,9 +118,6 @@ struct atao_private { ...@@ -118,9 +118,6 @@ struct atao_private {
unsigned short cfg1; unsigned short cfg1;
unsigned short cfg3; unsigned short cfg3;
/* Used for AO readback */
unsigned int ao_readback[10];
/* Used for caldac readback */ /* Used for caldac readback */
unsigned char caldac[21]; unsigned char caldac[21];
}; };
...@@ -141,9 +138,8 @@ static int atao_ao_insn_write(struct comedi_device *dev, ...@@ -141,9 +138,8 @@ static int atao_ao_insn_write(struct comedi_device *dev,
struct comedi_insn *insn, struct comedi_insn *insn,
unsigned int *data) unsigned int *data)
{ {
struct atao_private *devpriv = dev->private;
unsigned int chan = CR_CHAN(insn->chanspec); unsigned int chan = CR_CHAN(insn->chanspec);
unsigned int val; unsigned int val = s->readback[chan];
int i; int i;
if (chan == 0) if (chan == 0)
...@@ -151,12 +147,12 @@ static int atao_ao_insn_write(struct comedi_device *dev, ...@@ -151,12 +147,12 @@ static int atao_ao_insn_write(struct comedi_device *dev,
for (i = 0; i < insn->n; i++) { for (i = 0; i < insn->n; i++) {
val = data[i]; val = data[i];
devpriv->ao_readback[chan] = val;
/* munge offset binary (unsigned) to two's complement */ /* the hardware expects two's complement values */
val = comedi_offset_munge(s, val); outw(comedi_offset_munge(s, val),
outw(val, dev->iobase + ATAO_AO_REG(chan)); dev->iobase + ATAO_AO_REG(chan));
} }
s->readback[chan] = val;
if (chan == 0) if (chan == 0)
atao_select_reg_group(dev, 0); atao_select_reg_group(dev, 0);
...@@ -164,21 +160,6 @@ static int atao_ao_insn_write(struct comedi_device *dev, ...@@ -164,21 +160,6 @@ static int atao_ao_insn_write(struct comedi_device *dev,
return insn->n; return insn->n;
} }
static int atao_ao_insn_read(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn,
unsigned int *data)
{
struct atao_private *devpriv = dev->private;
unsigned int chan = CR_CHAN(insn->chanspec);
int i;
for (i = 0; i < insn->n; i++)
data[i] = devpriv->ao_readback[chan];
return insn->n;
}
static int atao_dio_insn_bits(struct comedi_device *dev, static int atao_dio_insn_bits(struct comedi_device *dev,
struct comedi_subdevice *s, struct comedi_subdevice *s,
struct comedi_insn *insn, struct comedi_insn *insn,
...@@ -363,7 +344,11 @@ static int atao_attach(struct comedi_device *dev, struct comedi_devconfig *it) ...@@ -363,7 +344,11 @@ static int atao_attach(struct comedi_device *dev, struct comedi_devconfig *it)
s->maxdata = 0x0fff; s->maxdata = 0x0fff;
s->range_table = it->options[3] ? &range_unipolar10 : &range_bipolar10; s->range_table = it->options[3] ? &range_unipolar10 : &range_bipolar10;
s->insn_write = atao_ao_insn_write; s->insn_write = atao_ao_insn_write;
s->insn_read = atao_ao_insn_read; s->insn_read = comedi_readback_insn_read;
ret = comedi_alloc_subdev_readback(s);
if (ret)
return ret;
/* Digital I/O subdevice */ /* Digital I/O subdevice */
s = &dev->subdevices[1]; s = &dev->subdevices[1];
......
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