staging: comedi: ni_mio_common: use insn->n in ni_eeprom_insn_read()
authorIan Abbott <abbotti@mev.co.uk>
Tue, 19 Mar 2019 16:54:43 +0000 (16:54 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 20 Mar 2019 07:25:17 +0000 (08:25 +0100)
commit018768ccc7dc582519b84df593dd8ff1fbd02b55
treebcf454a586acb640859c96e4565e3bcf749f572c
parent776d25ff5b494be280caba9d297477270462e580
staging: comedi: ni_mio_common: use insn->n in ni_eeprom_insn_read()

The `insn_read` handler for the EEPROM subdevice on E-series boards
(`ni_eeprom_insn_read()`) currently ignores `insn->n` (the number of
samples to read) and assumes a single sample is to be read into
`data[0]`.  Fortunately, the Comedi core ensures that `data[]` has a
length of at least 16 so there is no problem with array bounds.

The usual Comedi convention for `insn_read` handlers is to read the same
channel `insn->n` times into successive elements of `data[]` so let's do
that.  (Each channel number corresponds to a single EEPROM address.)
Since we do not expect the EEPROM data at a particular address to change
between readings, let's just read it once and copy the value `insn->n`
times.

Also, follow the usual Comedi convention and return `insn->n` from the
handler to indicate success (although any non-negative value will do).

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/comedi/drivers/ni_mio_common.c