]> git.baikalelectronics.ru Git - kernel.git/commit
staging: comedi: 8255: refactor subdev_8255_insn function
authorH Hartley Sweeten <hartleys@visionengravers.com>
Wed, 13 Jun 2012 22:42:45 +0000 (15:42 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 14 Jun 2012 00:19:16 +0000 (17:19 -0700)
commitdce3212f24ee5340b10841b02987276865007830
tree04b84e86fbfc04cc731eb8e890de565ae5581702
parent53bdfe0cf93e8706e04c581af103cd25393c47b4
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>
drivers/staging/comedi/drivers/8255.c