staging: comedi: ni_tio: Use data[insn->n-1] in ni_tio_insn_write()
authorIan Abbott <abbotti@mev.co.uk>
Wed, 27 Mar 2019 15:15:15 +0000 (15:15 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 29 Mar 2019 16:10:18 +0000 (17:10 +0100)
commit5c724e197eb57336696a0a573b199a273db9466b
treef7f1fc27d9b33bd1ba8004e62869a9f0aca62ec6
parent81a6e1cc312ea43b4a23e6f371dda1bd233ea750
staging: comedi: ni_tio: Use data[insn->n-1] in ni_tio_insn_write()

The `insn_write` handler for the counter subdevices
(`ni_tio_insn_write()`) writes a single data value `data[0]` to the
channel.  Technically, `insn->n` specifies the number of successive
values from `data[]` to write to the channel, but when there is little
benefit in writing multiple data values, the usual Comedi convention is
to just write the last data value `data[insn->n - 1]`.  Change the
function to follow that convention and use `data[insn->n - 1]` instead
of `data[0]`.  (In practice, `insn->n` would normally be 1 anyway.)

Also follow the usual Comedi convention and return `insn->n` from the
handler to indicate success instead of 0 (although any non-negative
return 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_tio.c