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

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
...@@ -100,9 +100,6 @@ struct mf6x4_private { ...@@ -100,9 +100,6 @@ struct mf6x4_private {
* offsets -- this variable makes the access easier * offsets -- this variable makes the access easier
*/ */
void __iomem *gpioc_R; 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, static int mf6x4_di_insn_bits(struct comedi_device *dev,
...@@ -181,7 +178,7 @@ static int mf6x4_ao_insn_write(struct comedi_device *dev, ...@@ -181,7 +178,7 @@ static int mf6x4_ao_insn_write(struct comedi_device *dev,
{ {
struct mf6x4_private *devpriv = dev->private; struct mf6x4_private *devpriv = dev->private;
unsigned int chan = CR_CHAN(insn->chanspec); unsigned int chan = CR_CHAN(insn->chanspec);
unsigned int val = devpriv->ao_readback[chan]; unsigned int val = s->readback[chan];
uint32_t gpioc; uint32_t gpioc;
int i; int i;
...@@ -194,21 +191,7 @@ static int mf6x4_ao_insn_write(struct comedi_device *dev, ...@@ -194,21 +191,7 @@ static int mf6x4_ao_insn_write(struct comedi_device *dev,
val = data[i]; val = data[i];
iowrite16(val, dev->mmio + MF6X4_DAC_R(chan)); iowrite16(val, dev->mmio + MF6X4_DAC_R(chan));
} }
devpriv->ao_readback[chan] = val; s->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];
return insn->n; return insn->n;
} }
...@@ -276,7 +259,11 @@ static int mf6x4_auto_attach(struct comedi_device *dev, unsigned long context) ...@@ -276,7 +259,11 @@ static int mf6x4_auto_attach(struct comedi_device *dev, unsigned long context)
s->maxdata = 0x3fff; /* 14 bits DAC */ s->maxdata = 0x3fff; /* 14 bits DAC */
s->range_table = &range_bipolar10; s->range_table = &range_bipolar10;
s->insn_write = mf6x4_ao_insn_write; 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 */ /* DIN */
s = &dev->subdevices[2]; s = &dev->subdevices[2];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment