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

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

Remove the unused private data and its allocation.
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 921f1b2e
...@@ -44,10 +44,6 @@ ...@@ -44,10 +44,6 @@
#define FL512_AO_DATA_REG(x) (0x04 + ((x) * 2)) #define FL512_AO_DATA_REG(x) (0x04 + ((x) * 2))
#define FL512_AO_TRIG_REG(x) (0x04 + ((x) * 2)) #define FL512_AO_TRIG_REG(x) (0x04 + ((x) * 2))
struct fl512_private {
unsigned short ao_readback[2];
};
static const struct comedi_lrange range_fl512 = { static const struct comedi_lrange range_fl512 = {
4, { 4, {
BIP_RANGE(0.5), BIP_RANGE(0.5),
...@@ -92,9 +88,8 @@ static int fl512_ao_insn_write(struct comedi_device *dev, ...@@ -92,9 +88,8 @@ static int fl512_ao_insn_write(struct comedi_device *dev,
struct comedi_insn *insn, struct comedi_insn *insn,
unsigned int *data) unsigned int *data)
{ {
struct fl512_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];
int i; int i;
for (i = 0; i < insn->n; i++) { for (i = 0; i < insn->n; i++) {
...@@ -105,29 +100,13 @@ static int fl512_ao_insn_write(struct comedi_device *dev, ...@@ -105,29 +100,13 @@ static int fl512_ao_insn_write(struct comedi_device *dev,
outb((val >> 8) & 0xf, dev->iobase + FL512_AO_DATA_REG(chan)); outb((val >> 8) & 0xf, dev->iobase + FL512_AO_DATA_REG(chan));
inb(dev->iobase + FL512_AO_TRIG_REG(chan)); inb(dev->iobase + FL512_AO_TRIG_REG(chan));
} }
devpriv->ao_readback[chan] = val; s->readback[chan] = val;
return insn->n;
}
static int fl512_ao_insn_read(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn,
unsigned int *data)
{
struct fl512_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;
} }
static int fl512_attach(struct comedi_device *dev, struct comedi_devconfig *it) static int fl512_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{ {
struct fl512_private *devpriv;
struct comedi_subdevice *s; struct comedi_subdevice *s;
int ret; int ret;
...@@ -135,10 +114,6 @@ static int fl512_attach(struct comedi_device *dev, struct comedi_devconfig *it) ...@@ -135,10 +114,6 @@ static int fl512_attach(struct comedi_device *dev, struct comedi_devconfig *it)
if (ret) if (ret)
return ret; return ret;
devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv));
if (!devpriv)
return -ENOMEM;
ret = comedi_alloc_subdevices(dev, 2); ret = comedi_alloc_subdevices(dev, 2);
if (ret) if (ret)
return ret; return ret;
...@@ -160,7 +135,11 @@ static int fl512_attach(struct comedi_device *dev, struct comedi_devconfig *it) ...@@ -160,7 +135,11 @@ static int fl512_attach(struct comedi_device *dev, struct comedi_devconfig *it)
s->maxdata = 0x0fff; s->maxdata = 0x0fff;
s->range_table = &range_fl512; s->range_table = &range_fl512;
s->insn_write = fl512_ao_insn_write; s->insn_write = fl512_ao_insn_write;
s->insn_read = fl512_ao_insn_read; s->insn_read = comedi_readback_insn_read;
ret = comedi_alloc_subdev_readback(s);
if (ret)
return ret;
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