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

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

For aesthetics, rename the (*insn_write) function and tidy it up.
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 da1eed18
......@@ -97,10 +97,6 @@ static const struct aio12_8_boardtype board_types[] = {
},
};
struct aio12_8_private {
unsigned int ao_readback[4];
};
static int aio_aio12_8_ai_eoc(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn,
......@@ -149,28 +145,13 @@ static int aio_aio12_8_ai_read(struct comedi_device *dev,
return insn->n;
}
static int aio_aio12_8_ao_read(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
struct aio12_8_private *devpriv = dev->private;
unsigned int chan = CR_CHAN(insn->chanspec);
int val = devpriv->ao_readback[chan];
int i;
for (i = 0; i < insn->n; i++)
data[i] = val;
return insn->n;
}
static int aio_aio12_8_ao_write(struct comedi_device *dev,
static int aio_aio12_8_ao_insn_write(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
struct comedi_insn *insn,
unsigned int *data)
{
struct aio12_8_private *devpriv = dev->private;
unsigned int chan = CR_CHAN(insn->chanspec);
unsigned long port = dev->iobase + AIO12_8_DAC_REG(chan);
unsigned int val = 0;
unsigned int val = s->readback[chan];
int i;
/* enable DACs */
......@@ -178,10 +159,9 @@ static int aio_aio12_8_ao_write(struct comedi_device *dev,
for (i = 0; i < insn->n; i++) {
val = data[i];
outw(val, port);
outw(val, dev->iobase + AIO12_8_DAC_REG(chan));
}
devpriv->ao_readback[chan] = val;
s->readback[chan] = val;
return insn->n;
}
......@@ -199,7 +179,6 @@ static int aio_aio12_8_attach(struct comedi_device *dev,
struct comedi_devconfig *it)
{
const struct aio12_8_boardtype *board = comedi_board(dev);
struct aio12_8_private *devpriv;
struct comedi_subdevice *s;
int ret;
......@@ -207,10 +186,6 @@ static int aio_aio12_8_attach(struct comedi_device *dev,
if (ret)
return ret;
devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv));
if (!devpriv)
return -ENOMEM;
ret = comedi_alloc_subdevices(dev, 4);
if (ret)
return ret;
......@@ -236,8 +211,12 @@ static int aio_aio12_8_attach(struct comedi_device *dev,
s->n_chan = 4;
s->maxdata = 0x0fff;
s->range_table = &range_aio_aio12_8;
s->insn_read = aio_aio12_8_ao_read;
s->insn_write = aio_aio12_8_ao_write;
s->insn_write = aio_aio12_8_ao_insn_write;
s->insn_read = comedi_readback_insn_read;
ret = comedi_alloc_subdev_readback(s);
if (ret)
return ret;
} else {
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