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

staging: comedi: pcl818: 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 92b66775
...@@ -319,7 +319,6 @@ struct pcl818_private { ...@@ -319,7 +319,6 @@ struct pcl818_private {
unsigned int act_chanlist_len; /* how long is actual MUX list */ unsigned int act_chanlist_len; /* how long is actual MUX list */
unsigned int act_chanlist_pos; /* actual position in MUX list */ unsigned int act_chanlist_pos; /* actual position in MUX list */
unsigned int ai_data_len; /* len of data buffer */ unsigned int ai_data_len; /* len of data buffer */
unsigned int ao_readback[2];
unsigned int divisor1; unsigned int divisor1;
unsigned int divisor2; unsigned int divisor2;
unsigned int usefifo:1; unsigned int usefifo:1;
...@@ -937,32 +936,18 @@ static int pcl818_ao_insn_write(struct comedi_device *dev, ...@@ -937,32 +936,18 @@ static int pcl818_ao_insn_write(struct comedi_device *dev,
struct comedi_insn *insn, struct comedi_insn *insn,
unsigned int *data) unsigned int *data)
{ {
struct pcl818_private *devpriv = dev->private;
unsigned int chan = CR_CHAN(insn->chanspec); unsigned int chan = CR_CHAN(insn->chanspec);
unsigned int val = s->readback[chan];
int i; int i;
for (i = 0; i < insn->n; i++) { for (i = 0; i < insn->n; i++) {
devpriv->ao_readback[chan] = data[i]; val = data[i];
outb((data[i] & 0x000f) << 4, outb((val & 0x000f) << 4,
dev->iobase + PCL818_AO_LSB_REG(chan)); dev->iobase + PCL818_AO_LSB_REG(chan));
outb((data[i] & 0x0ff0) >> 4, outb((val & 0x0ff0) >> 4,
dev->iobase + PCL818_AO_MSB_REG(chan)); dev->iobase + PCL818_AO_MSB_REG(chan));
} }
s->readback[chan] = val;
return insn->n;
}
static int pcl818_ao_insn_read(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn,
unsigned int *data)
{
struct pcl818_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; return insn->n;
} }
...@@ -1172,8 +1157,6 @@ static int pcl818_attach(struct comedi_device *dev, struct comedi_devconfig *it) ...@@ -1172,8 +1157,6 @@ static int pcl818_attach(struct comedi_device *dev, struct comedi_devconfig *it)
s->n_chan = board->n_aochan; s->n_chan = board->n_aochan;
s->maxdata = 0x0fff; s->maxdata = 0x0fff;
s->range_table = &range_unipolar5; s->range_table = &range_unipolar5;
s->insn_read = pcl818_ao_insn_read;
s->insn_write = pcl818_ao_insn_write;
if (board->is_818) { if (board->is_818) {
if ((it->options[4] == 1) || (it->options[4] == 10)) if ((it->options[4] == 1) || (it->options[4] == 10))
s->range_table = &range_unipolar10; s->range_table = &range_unipolar10;
...@@ -1185,6 +1168,12 @@ static int pcl818_attach(struct comedi_device *dev, struct comedi_devconfig *it) ...@@ -1185,6 +1168,12 @@ static int pcl818_attach(struct comedi_device *dev, struct comedi_devconfig *it)
if (it->options[5] == 2) if (it->options[5] == 2)
s->range_table = &range_unknown; s->range_table = &range_unknown;
} }
s->insn_write = pcl818_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