Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 72e35fd3 authored by H Hartley Sweeten's avatar H Hartley Sweeten Committed by Greg Kroah-Hartman
Browse files

staging: comedi: ni_at_ao: 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: 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 096b4b0a
Loading
Loading
Loading
Loading
+10 −25
Original line number Diff line number Diff line
@@ -118,9 +118,6 @@ struct atao_private {
	unsigned short cfg1;
	unsigned short cfg3;

	/* Used for AO readback */
	unsigned int ao_readback[10];

	/* Used for caldac readback */
	unsigned char caldac[21];
};
@@ -141,9 +138,8 @@ static int atao_ao_insn_write(struct comedi_device *dev,
			      struct comedi_insn *insn,
			      unsigned int *data)
{
	struct atao_private *devpriv = dev->private;
	unsigned int chan = CR_CHAN(insn->chanspec);
	unsigned int val;
	unsigned int val = s->readback[chan];
	int i;

	if (chan == 0)
@@ -151,12 +147,12 @@ static int atao_ao_insn_write(struct comedi_device *dev,

	for (i = 0; i < insn->n; i++) {
		val = data[i];
		devpriv->ao_readback[chan] = val;

		/* munge offset binary (unsigned) to two's complement */
		val = comedi_offset_munge(s, val);
		outw(val, dev->iobase + ATAO_AO_REG(chan));
		/* the hardware expects two's complement values */
		outw(comedi_offset_munge(s, val),
		     dev->iobase + ATAO_AO_REG(chan));
	}
	s->readback[chan] = val;

	if (chan == 0)
		atao_select_reg_group(dev, 0);
@@ -164,21 +160,6 @@ static int atao_ao_insn_write(struct comedi_device *dev,
	return insn->n;
}

static int atao_ao_insn_read(struct comedi_device *dev,
			     struct comedi_subdevice *s,
			     struct comedi_insn *insn,
			     unsigned int *data)
{
	struct atao_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;
}

static int atao_dio_insn_bits(struct comedi_device *dev,
			      struct comedi_subdevice *s,
			      struct comedi_insn *insn,
@@ -363,7 +344,11 @@ static int atao_attach(struct comedi_device *dev, struct comedi_devconfig *it)
	s->maxdata	= 0x0fff;
	s->range_table	= it->options[3] ? &range_unipolar10 : &range_bipolar10;
	s->insn_write	= atao_ao_insn_write;
	s->insn_read	= atao_ao_insn_read;
	s->insn_read	= comedi_readback_insn_read;

	ret = comedi_alloc_subdev_readback(s);
	if (ret)
		return ret;

	/* Digital I/O subdevice */
	s = &dev->subdevices[1];