unsigned short control_1; /* Mirror of CONTROL_1 register */
unsigned short control_2; /* Mirror of CONTROL_2 register */
unsigned short dac_control; /* Mirror of the DAC_CONTROL register */
- int ao_readback[4]; /* Mirror of analog output data */
};
static inline void sleep(unsigned sec)
struct me_private_data *dev_private = dev->private;
unsigned int chan = CR_CHAN(insn->chanspec);
unsigned int rang = CR_RANGE(insn->chanspec);
- unsigned int val = dev_private->ao_readback[chan];
+ unsigned int val = s->readback[chan];
int i;
/* Enable all DAC */
writew(val, dev->mmio + ME_DAC_DATA_A + (chan << 1));
}
- dev_private->ao_readback[chan] = val;
+ s->readback[chan] = val;
/* Update dac with data registers */
readw(dev->mmio + ME_DAC_UPDATE);
return insn->n;
}
-static int me_ao_insn_read(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn,
- unsigned int *data)
-{
- struct me_private_data *dev_private = dev->private;
- unsigned int chan = CR_CHAN(insn->chanspec);
- int i;
-
- for (i = 0; i < insn->n; i++)
- data[i] = dev_private->ao_readback[chan];
-
- return insn->n;
-}
-
static int me2600_xilinx_download(struct comedi_device *dev,
const u8 *data, size_t size,
unsigned long context)
s->maxdata = 0x0fff;
s->len_chanlist = 4;
s->range_table = &me_ao_range;
- s->insn_read = me_ao_insn_read;
s->insn_write = me_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;
}