diff options
author | Ian Abbott | 2018-10-30 15:17:12 +0100 |
---|---|---|
committer | Greg Kroah-Hartman | 2018-11-07 13:05:38 +0100 |
commit | b33fc68c26a56d23b7221434dd367949420637bc (patch) | |
tree | 0d57875ca3674b71ffdfa2bc0c251473374e423d /drivers/staging/comedi | |
parent | staging: comedi: cb_pcidas64: Use insn->n in AO insn_write handler (diff) | |
download | kernel-qcow2-linux-b33fc68c26a56d23b7221434dd367949420637bc.tar.gz kernel-qcow2-linux-b33fc68c26a56d23b7221434dd367949420637bc.tar.xz kernel-qcow2-linux-b33fc68c26a56d23b7221434dd367949420637bc.zip |
staging: comedi: cb_pcidas64: Use insn->n in EEPROM insn_read handler
The `insn_read` handler for the EEPROM subdevice (`eeprom_insn_read()`)
currently ignores `insn->n` (the number of samples to be read) and
assumes a single sample is to be read. But `insn->n` could be 0,
meaning no samples should be read, in which case `data[0]` ought not to
be written. (The comedi core at least ensures that `data[0]` exists,
but we should not rely on that.)
Follow the usual Comedi guidelines and interpret `insn->n` as the number
of samples to be read, but only read the EEPROM location once and make
`insn->n` copies, as we don't expect the contents of the EEPROM location
to change between readings.
Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/comedi')
-rw-r--r-- | drivers/staging/comedi/drivers/cb_pcidas64.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/drivers/staging/comedi/drivers/cb_pcidas64.c b/drivers/staging/comedi/drivers/cb_pcidas64.c index 44e5aaf8bae5..e1774e09a320 100644 --- a/drivers/staging/comedi/drivers/cb_pcidas64.c +++ b/drivers/staging/comedi/drivers/cb_pcidas64.c @@ -3768,9 +3768,17 @@ static int eeprom_read_insn(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { - data[0] = read_eeprom(dev, CR_CHAN(insn->chanspec)); + unsigned int val; + unsigned int i; - return 1; + if (insn->n) { + /* No point reading the same EEPROM location more than once. */ + val = read_eeprom(dev, CR_CHAN(insn->chanspec)); + for (i = 0; i < insn->n; i++) + data[i] = val; + } + + return insn->n; } /* Allocate and initialize the subdevice structures. */ |