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

staging: comedi: ni_670x: cleanup ni_670x_ao_winsn()

For aesthetics, rename this function and tidy it up a bit.
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 b328ad30
...@@ -86,35 +86,37 @@ struct ni_670x_private { ...@@ -86,35 +86,37 @@ struct ni_670x_private {
unsigned int ao_readback[32]; unsigned int ao_readback[32];
}; };
static int ni_670x_ao_winsn(struct comedi_device *dev, static int ni_670x_ao_insn_write(struct comedi_device *dev,
struct comedi_subdevice *s, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data) struct comedi_insn *insn,
unsigned int *data)
{ {
struct ni_670x_private *devpriv = dev->private; struct ni_670x_private *devpriv = dev->private;
unsigned int chan = CR_CHAN(insn->chanspec);
unsigned int val = devpriv->ao_readback[chan];
int i; int i;
int chan = CR_CHAN(insn->chanspec);
/* Channel number mapping :
NI 6703/ NI 6704 | NI 6704 Only
----------------------------------------------------
vch(0) : 0 | ich(16) : 1
vch(1) : 2 | ich(17) : 3
. : . | . .
. : . | . .
. : . | . .
vch(15) : 30 | ich(31) : 31 */
/*
* Channel number mapping:
*
* NI 6703/ NI 6704 | NI 6704 Only
* -------------------------------
* vch(0) : 0 | ich(16) : 1
* vch(1) : 2 | ich(17) : 3
* ... | ...
* vch(15) : 30 | ich(31) : 31
*/
for (i = 0; i < insn->n; i++) { for (i = 0; i < insn->n; i++) {
val = data[i];
/* First write in channel register which channel to use */ /* First write in channel register which channel to use */
writel(((chan & 15) << 1) | ((chan & 16) >> 4), writel(((chan & 15) << 1) | ((chan & 16) >> 4),
dev->mmio + AO_CHAN_OFFSET); dev->mmio + AO_CHAN_OFFSET);
/* write channel value */ /* write channel value */
writel(data[i], dev->mmio + AO_VALUE_OFFSET); writel(val, dev->mmio + AO_VALUE_OFFSET);
devpriv->ao_readback[chan] = data[i];
} }
devpriv->ao_readback[chan] = val;
return i; return insn->n;
} }
static int ni_670x_ao_rinsn(struct comedi_device *dev, static int ni_670x_ao_rinsn(struct comedi_device *dev,
...@@ -241,7 +243,7 @@ static int ni_670x_auto_attach(struct comedi_device *dev, ...@@ -241,7 +243,7 @@ static int ni_670x_auto_attach(struct comedi_device *dev,
} else { } else {
s->range_table = &range_bipolar10; s->range_table = &range_bipolar10;
} }
s->insn_write = &ni_670x_ao_winsn; s->insn_write = ni_670x_ao_insn_write;
s->insn_read = &ni_670x_ao_rinsn; s->insn_read = &ni_670x_ao_rinsn;
s = &dev->subdevices[1]; s = &dev->subdevices[1];
......
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