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

staging: comedi: pcl812: 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.

For aesthetics, tidy up pcl812_ao_insn_write().
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 18259ffc
...@@ -522,7 +522,6 @@ struct pcl812_private { ...@@ -522,7 +522,6 @@ struct pcl812_private {
unsigned int dma_runs_to_end; /* how many times we must switch DMA buffers */ unsigned int dma_runs_to_end; /* how many times we must switch DMA buffers */
unsigned int last_dma_run; /* how many bytes to transfer on last DMA buffer */ unsigned int last_dma_run; /* how many bytes to transfer on last DMA buffer */
unsigned int max_812_ai_mode0_rangewait; /* setling time for gain */ unsigned int max_812_ai_mode0_rangewait; /* setling time for gain */
unsigned int ao_readback[2]; /* data for AO readback */
unsigned int divisor1; unsigned int divisor1;
unsigned int divisor2; unsigned int divisor2;
unsigned int use_diff:1; unsigned int use_diff:1;
...@@ -1039,32 +1038,16 @@ static int pcl812_ao_insn_write(struct comedi_device *dev, ...@@ -1039,32 +1038,16 @@ static int pcl812_ao_insn_write(struct comedi_device *dev,
struct comedi_insn *insn, struct comedi_insn *insn,
unsigned int *data) unsigned int *data)
{ {
struct pcl812_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++) {
outb((data[i] & 0xff), val = data[i];
dev->iobase + PCL812_AO_LSB_REG(chan)); outb(val & 0xff, dev->iobase + PCL812_AO_LSB_REG(chan));
outb((data[i] >> 8) & 0x0f, outb((val >> 8) & 0x0f, dev->iobase + PCL812_AO_MSB_REG(chan));
dev->iobase + PCL812_AO_MSB_REG(chan));
devpriv->ao_readback[chan] = data[i];
} }
s->readback[chan] = val;
return insn->n;
}
static int pcl812_ao_insn_read(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn,
unsigned int *data)
{
struct pcl812_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;
} }
...@@ -1336,8 +1319,6 @@ static int pcl812_attach(struct comedi_device *dev, struct comedi_devconfig *it) ...@@ -1336,8 +1319,6 @@ static int pcl812_attach(struct comedi_device *dev, struct comedi_devconfig *it)
s->n_chan = board->n_aochan; s->n_chan = board->n_aochan;
s->maxdata = 0xfff; s->maxdata = 0xfff;
s->range_table = &range_unipolar5; s->range_table = &range_unipolar5;
s->insn_read = pcl812_ao_insn_read;
s->insn_write = pcl812_ao_insn_write;
switch (board->board_type) { switch (board->board_type) {
case boardA821: case boardA821:
if (it->options[3] == 1) if (it->options[3] == 1)
...@@ -1353,6 +1334,13 @@ static int pcl812_attach(struct comedi_device *dev, struct comedi_devconfig *it) ...@@ -1353,6 +1334,13 @@ static int pcl812_attach(struct comedi_device *dev, struct comedi_devconfig *it)
s->range_table = &range_unknown; s->range_table = &range_unknown;
break; break;
} }
s->insn_write = pcl812_ao_insn_write;
s->insn_read = comedi_readback_insn_read;
ret = comedi_alloc_subdev_readback(s);
if (ret)
return ret;
subdev++; subdev++;
} }
......
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