summaryrefslogtreecommitdiff
path: root/drivers/staging/comedi
diff options
context:
space:
mode:
authorIan Abbott <abbotti@mev.co.uk>2019-03-19 16:54:44 +0000
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2019-03-20 08:25:17 +0100
commit49634aa7d9e65c8973745544ceb0b854e24c08e2 (patch)
treea8d9dbb925e90c5c3b8b7704617f0b47f756b0fd /drivers/staging/comedi
parent018768ccc7dc582519b84df593dd8ff1fbd02b55 (diff)
staging: comedi: ni_mio_common: use insn->n in ni_m_series_eeprom_insn_read()
The `insn_read` handler for the EEPROM subdevice on M-series boards (`ni_m_series_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 corresponds to a single EEPROM address.) In this case, the data value comes from a local copy of the EEPROM contents. 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>
Diffstat (limited to 'drivers/staging/comedi')
-rw-r--r--drivers/staging/comedi/drivers/ni_mio_common.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c
index 5b397ad2a604..5eef1a63e3eb 100644
--- a/drivers/staging/comedi/drivers/ni_mio_common.c
+++ b/drivers/staging/comedi/drivers/ni_mio_common.c
@@ -4524,10 +4524,12 @@ static int ni_m_series_eeprom_insn_read(struct comedi_device *dev,
unsigned int *data)
{
struct ni_private *devpriv = dev->private;
+ unsigned int i;
- data[0] = devpriv->eeprom_buffer[CR_CHAN(insn->chanspec)];
+ for (i = 0; i < insn->n; i++)
+ data[i] = devpriv->eeprom_buffer[CR_CHAN(insn->chanspec)];
- return 1;
+ return insn->n;
}
static unsigned int ni_old_get_pfi_routing(struct comedi_device *dev,