staging: comedi: 8255: refactor subdev_8255_insn function
Refactor the subdev_8255_insn function to follow what the user
space library is doing.
1) This function requires 'data' to contain 2 parameters. Add a
sanity check for this (insn->n != 2).
2) The 'data' parameters are actually a 'mask' of the valid bits and
the actual 'bits' to modify. Create local variables of these names
to help with maintainability.
3) The value returned in data[1] reflects the actual state of the
8255 io pins after the update of the masked bits. Fetch this data
in a local variable and then set data[1].
4) The user space library only checks for a < 0 return to indicate
an error. It appears that the 'return 2' in this function is supposed
to indicate the number of data parameters used to perform the command.
Return the insn->n value for this, the open coded '2' looks wrong.
Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Iam Abbott <abbotti@mev.co.uk>
Cc: Frank Mori Hess <fmhess@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>