From: Ian Abbott Date: Tue, 19 Mar 2019 16:54:42 +0000 (+0000) Subject: staging: comedi: ni_mio_common: use insn->n in ni_calib_insn_read() X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=776d25ff5b494be280caba9d297477270462e580;p=openwrt%2Fstaging%2Fblogic.git staging: comedi: ni_mio_common: use insn->n in ni_calib_insn_read() The `insn_read` handler for the calibration subdevice (`ni_calib_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. 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 Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index 613b6b2abf7d..e008095436d7 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -4409,10 +4409,12 @@ static int ni_calib_insn_read(struct comedi_device *dev, unsigned int *data) { struct ni_private *devpriv = dev->private; + unsigned int i; - data[0] = devpriv->caldacs[CR_CHAN(insn->chanspec)]; + for (i = 0; i < insn->n; i++) + data[0] = devpriv->caldacs[CR_CHAN(insn->chanspec)]; - return 1; + return insn->n; } static void caldac_setup(struct comedi_device *dev, struct comedi_subdevice *s)