]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commit
staging: comedi: addi_apci_3501: Use insn->n in EEPROM insn_read handler
authorIan Abbott <abbotti@mev.co.uk>
Wed, 31 Oct 2018 12:29:56 +0000 (12:29 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 7 Nov 2018 12:05:39 +0000 (13:05 +0100)
commit48164754d7fe219911b7653449a4ce85d23c3556
treebb0d7c2aff7011efca1cf02a116687da2de1d822
parente3b9ea9aae7e1576516da2b125d7add20663f591
staging: comedi: addi_apci_3501: Use insn->n in EEPROM insn_read handler

The `insn_read` handler for the EEPROM subdevice
(`apci3501_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.)

Following 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/addi_apci_3501.c