unsigned int ao_readback[32];
};
-static int ni_670x_ao_winsn(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data)
+static int ni_670x_ao_insn_write(struct comedi_device *dev,
+ struct comedi_subdevice *s,
+ struct comedi_insn *insn,
+ unsigned int *data)
{
struct ni_670x_private *devpriv = dev->private;
+ unsigned int chan = CR_CHAN(insn->chanspec);
+ unsigned int val = devpriv->ao_readback[chan];
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++) {
+ val = data[i];
/* First write in channel register which channel to use */
writel(((chan & 15) << 1) | ((chan & 16) >> 4),
dev->mmio + AO_CHAN_OFFSET);
/* write channel value */
- writel(data[i], dev->mmio + AO_VALUE_OFFSET);
- devpriv->ao_readback[chan] = data[i];
+ writel(val, dev->mmio + AO_VALUE_OFFSET);
}
+ devpriv->ao_readback[chan] = val;
- return i;
+ return insn->n;
}
static int ni_670x_ao_rinsn(struct comedi_device *dev,
} else {
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 = &dev->subdevices[1];