staging: comedi: cb_pcidas64: Use insn->n in EEPROM insn_read handler
authorIan Abbott <abbotti@mev.co.uk>
Tue, 30 Oct 2018 14:17:12 +0000 (14:17 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 7 Nov 2018 12:05:38 +0000 (13:05 +0100)
commitb33fc68c26a56d23b7221434dd367949420637bc
tree0d57875ca3674b71ffdfa2bc0c251473374e423d
parent130151991dcb14e5c383c730b3ef37a6fdc32c95
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>
drivers/staging/comedi/drivers/cb_pcidas64.c