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

staging: comedi: pcmda12: 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 72e35fd3
...@@ -61,7 +61,6 @@ static const struct comedi_lrange pcmda12_ranges = { ...@@ -61,7 +61,6 @@ static const struct comedi_lrange pcmda12_ranges = {
}; };
struct pcmda12_private { struct pcmda12_private {
unsigned int ao_readback[8];
int simultaneous_xfer_mode; int simultaneous_xfer_mode;
}; };
...@@ -72,7 +71,7 @@ static int pcmda12_ao_insn_write(struct comedi_device *dev, ...@@ -72,7 +71,7 @@ static int pcmda12_ao_insn_write(struct comedi_device *dev,
{ {
struct pcmda12_private *devpriv = dev->private; struct pcmda12_private *devpriv = dev->private;
unsigned int chan = CR_CHAN(insn->chanspec); unsigned int chan = CR_CHAN(insn->chanspec);
unsigned int val = devpriv->ao_readback[chan]; unsigned int val = s->readback[chan];
unsigned long ioreg = dev->iobase + (chan * 2); unsigned long ioreg = dev->iobase + (chan * 2);
int i; int i;
...@@ -88,7 +87,7 @@ static int pcmda12_ao_insn_write(struct comedi_device *dev, ...@@ -88,7 +87,7 @@ static int pcmda12_ao_insn_write(struct comedi_device *dev,
if (!devpriv->simultaneous_xfer_mode) if (!devpriv->simultaneous_xfer_mode)
inb(ioreg); inb(ioreg);
} }
devpriv->ao_readback[chan] = val; s->readback[chan] = val;
return insn->n; return insn->n;
} }
...@@ -99,8 +98,6 @@ static int pcmda12_ao_insn_read(struct comedi_device *dev, ...@@ -99,8 +98,6 @@ static int pcmda12_ao_insn_read(struct comedi_device *dev,
unsigned int *data) unsigned int *data)
{ {
struct pcmda12_private *devpriv = dev->private; struct pcmda12_private *devpriv = dev->private;
unsigned int chan = CR_CHAN(insn->chanspec);
int i;
/* /*
* Initiate simultaneaous xfer mode by reading one of the * Initiate simultaneaous xfer mode by reading one of the
...@@ -109,10 +106,7 @@ static int pcmda12_ao_insn_read(struct comedi_device *dev, ...@@ -109,10 +106,7 @@ static int pcmda12_ao_insn_read(struct comedi_device *dev,
if (devpriv->simultaneous_xfer_mode) if (devpriv->simultaneous_xfer_mode)
inb(dev->iobase); inb(dev->iobase);
for (i = 0; i < insn->n; i++) return comedi_readback_insn_read(dev, s, insn, data);
data[i] = devpriv->ao_readback[chan];
return insn->n;
} }
static void pcmda12_ao_reset(struct comedi_device *dev, static void pcmda12_ao_reset(struct comedi_device *dev,
...@@ -158,6 +152,10 @@ static int pcmda12_attach(struct comedi_device *dev, ...@@ -158,6 +152,10 @@ static int pcmda12_attach(struct comedi_device *dev,
s->insn_write = pcmda12_ao_insn_write; s->insn_write = pcmda12_ao_insn_write;
s->insn_read = pcmda12_ao_insn_read; s->insn_read = pcmda12_ao_insn_read;
ret = comedi_alloc_subdev_readback(s);
if (ret)
return ret;
pcmda12_ao_reset(dev, s); pcmda12_ao_reset(dev, s);
return 0; return 0;
......
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