diff options
author | H Hartley Sweeten <hartleys@visionengravers.com> | 2012-10-25 22:09:33 (GMT) |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-10-26 16:20:02 (GMT) |
commit | 91b0da570722faf2e6a06f999e789405161943b5 (patch) | |
tree | fcc0eb6ee83e80ef04eb68482d30adc4c12f7d44 | |
parent | e43937926265ad417942c8ffb7be8bd185788335 (diff) | |
download | linux-fsl-qoriq-91b0da570722faf2e6a06f999e789405161943b5.tar.xz |
staging: comedi: me_daq: fix me_ao_insn_read()
This function is supposed to return the analog output value for
a specified channel. The channel number is packed in insn->chanspec,
which is an unsigned int, and unpacked using the CR_CHAN() macro.
Currently this function is trying to use the chanspec as an array.
This works only if a single data value is read.
Fix the function so that the desired channel is determined and all
the data returned is from that channel.
Also, fix the return. The comedi core expects insn_read functions to
return the number of data values (insn->n).
Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/staging/comedi/drivers/me_daq.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/drivers/staging/comedi/drivers/me_daq.c b/drivers/staging/comedi/drivers/me_daq.c index 1e4a980..1efad59 100644 --- a/drivers/staging/comedi/drivers/me_daq.c +++ b/drivers/staging/comedi/drivers/me_daq.c @@ -469,20 +469,19 @@ static int me_ao_insn_write(struct comedi_device *dev, return i; } -/* Analog output readback */ static int me_ao_insn_read(struct comedi_device *dev, - struct comedi_subdevice *s, struct comedi_insn *insn, + struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { struct me_private_data *dev_private = dev->private; + unsigned int chan = CR_CHAN(insn->chanspec); int i; - for (i = 0; i < insn->n; i++) { - data[i] = - dev_private->ao_readback[CR_CHAN((&insn->chanspec)[i])]; - } + for (i = 0; i < insn->n; i++) + data[i] = dev_private->ao_readback[chan]; - return 1; + return insn->n; } /* |