Commit 43818b03 authored by Ian Abbott's avatar Ian Abbott Committed by Greg Kroah-Hartman

staging: comedi: cb_pcidda: Use insn->n in AO insn_write handler

The `insn_write` handler for the AO subdevice
(`cb_pcidda_ao_insn_write()`) currently ignores `insn->n` (the number of
samples to write) and assumes a single sample is to be written.  But
`insn->n` could be 0, meaning no samples should be written, in which
case `data[0]` is invalid.

Follow the usual Comedi guidelines and change
`cb_pcidda_ao_insn_write()` to write the specified number of samples.
This fixes the assumption that `data[0]` is valid.
Signed-off-by: default avatarIan Abbott <abbotti@mev.co.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 48164754
......@@ -291,6 +291,7 @@ static int cb_pcidda_ao_insn_write(struct comedi_device *dev,
unsigned int channel = CR_CHAN(insn->chanspec);
unsigned int range = CR_RANGE(insn->chanspec);
unsigned int ctrl;
unsigned int i;
if (range != devpriv->ao_range[channel])
cb_pcidda_calibrate(dev, channel, range);
......@@ -317,7 +318,8 @@ static int cb_pcidda_ao_insn_write(struct comedi_device *dev,
outw(ctrl, devpriv->daqio + CB_DDA_DA_CTRL_REG);
outw(data[0], devpriv->daqio + CB_DDA_DA_DATA_REG(channel));
for (i = 0; i < insn->n; i++)
outw(data[i], devpriv->daqio + CB_DDA_DA_DATA_REG(channel));
return insn->n;
}
......
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