summaryrefslogtreecommitdiff
path: root/drivers/staging
diff options
context:
space:
mode:
authorIan Abbott <abbotti@mev.co.uk>2018-10-30 17:23:54 +0000
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2018-11-07 13:05:39 +0100
commit4a4c1b1d5a1d1f083ea9a9fe8b179bfa9e62e12a (patch)
tree28c21bacabd9a07a2308b2f33c15565454201fd0 /drivers/staging
parent43818b03c518b7aed6bbe95ce2bcd4c5aaed2473 (diff)
staging: comedi: ni_labpc_common: Use insn->n in AO insn_write handler
The `insn_write` handler for the AO subdevice (`labpc_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 `labpc_ao_insn_write()` to write the specified number of samples. This fixes the assumption that `data[0]` is valid. Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging')
-rw-r--r--drivers/staging/comedi/drivers/ni_labpc_common.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/drivers/staging/comedi/drivers/ni_labpc_common.c b/drivers/staging/comedi/drivers/ni_labpc_common.c
index 7fa2d39562db..406952f5521d 100644
--- a/drivers/staging/comedi/drivers/ni_labpc_common.c
+++ b/drivers/staging/comedi/drivers/ni_labpc_common.c
@@ -906,7 +906,9 @@ static int labpc_ao_insn_write(struct comedi_device *dev,
{
const struct labpc_boardinfo *board = dev->board_ptr;
struct labpc_private *devpriv = dev->private;
- int channel, range;
+ unsigned int channel;
+ unsigned int range;
+ unsigned int i;
unsigned long flags;
channel = CR_CHAN(insn->chanspec);
@@ -932,9 +934,10 @@ static int labpc_ao_insn_write(struct comedi_device *dev,
devpriv->write_byte(dev, devpriv->cmd6, CMD6_REG);
}
/* send data */
- labpc_ao_write(dev, s, channel, data[0]);
+ for (i = 0; i < insn->n; i++)
+ labpc_ao_write(dev, s, channel, data[i]);
- return 1;
+ return insn->n;
}
/* lowlevel write to eeprom/dac */