},
};
-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,
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,
- struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data)
+static int aio_aio12_8_ao_insn_write(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);
- unsigned long port = dev->iobase + AIO12_8_DAC_REG(chan);
- unsigned int val = 0;
+ unsigned int val = s->readback[chan];
int i;
/* enable DACs */
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;
}
struct comedi_devconfig *it)
{
const struct aio12_8_boardtype *board = comedi_board(dev);
- struct aio12_8_private *devpriv;
struct comedi_subdevice *s;
int ret;
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;
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;
}