staging: comedi: me_daq: 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: H Hartley Sweeten <hsweeten@visionengravers.com> Reviewed-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
61e9332b1c
commit
42c7b55cce
@ -171,7 +171,6 @@ struct me_private_data {
|
||||
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)
|
||||
@ -325,7 +324,7 @@ static int me_ao_insn_write(struct comedi_device *dev,
|
||||
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 */
|
||||
@ -358,7 +357,7 @@ static int me_ao_insn_write(struct comedi_device *dev,
|
||||
|
||||
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);
|
||||
@ -366,21 +365,6 @@ static int me_ao_insn_write(struct comedi_device *dev,
|
||||
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)
|
||||
@ -532,8 +516,12 @@ static int me_auto_attach(struct comedi_device *dev,
|
||||
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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user