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

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

staging: comedi: mf6x4: 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 496e7cd9
Loading
Loading
Loading
Loading
+7 −20
Original line number Diff line number Diff line
@@ -100,9 +100,6 @@ struct mf6x4_private {
	 * offsets -- this variable makes the access easier
	 */
	void __iomem *gpioc_R;

	/* DAC value cache -- used for insn_read function */
	int ao_readback[8];
};

static int mf6x4_di_insn_bits(struct comedi_device *dev,
@@ -181,7 +178,7 @@ static int mf6x4_ao_insn_write(struct comedi_device *dev,
{
	struct mf6x4_private *devpriv = dev->private;
	unsigned int chan = CR_CHAN(insn->chanspec);
	unsigned int val = devpriv->ao_readback[chan];
	unsigned int val = s->readback[chan];
	uint32_t gpioc;
	int i;

@@ -194,21 +191,7 @@ static int mf6x4_ao_insn_write(struct comedi_device *dev,
		val = data[i];
		iowrite16(val, dev->mmio + MF6X4_DAC_R(chan));
	}
	devpriv->ao_readback[chan] = val;

	return insn->n;
}

static int mf6x4_ao_insn_read(struct comedi_device *dev,
			      struct comedi_subdevice *s,
			      struct comedi_insn *insn, unsigned int *data)
{
	struct mf6x4_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];
	s->readback[chan] = val;

	return insn->n;
}
@@ -276,7 +259,11 @@ static int mf6x4_auto_attach(struct comedi_device *dev, unsigned long context)
	s->maxdata = 0x3fff; /* 14 bits DAC */
	s->range_table = &range_bipolar10;
	s->insn_write = mf6x4_ao_insn_write;
	s->insn_read = mf6x4_ao_insn_read;
	s->insn_read = comedi_readback_insn_read;

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

	/* DIN */
	s = &dev->subdevices[2];