]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commit
staging: comedi: amplc_pci230: simplify pci230_ao_mangle_datum()
authorIan Abbott <abbotti@mev.co.uk>
Mon, 1 Sep 2014 11:03:46 +0000 (12:03 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 2 Sep 2014 18:21:31 +0000 (11:21 -0700)
commit9405d8724045a84c960a1e4ac9876cf5fb1de35e
treeccaf6cb1cb518fdc5f325fa9a44b3c53440b0f27
parent33af02c7b259a60dca2cd1ca11a4568dcc000113
staging: comedi: amplc_pci230: simplify pci230_ao_mangle_datum()

`pci230_ao_mangle_datum()` converts comedi sample values for the AO
subdevice to hardware register values.  The comedi sample value will be
an unsigned value in the range 0 to 4095 (assuming 12-bit resolution).
The hardware wants the value shifted so the m.s. bit of the sample in in
bit 15.  If set to a bipolar range, it also expects a 2's complement
value, so the top bit of the sample value needs to be inverted in that
case.

Simplify the existing code by doing the 2's complement conversion after
the shift.  That way, it is always bit 15 that is inverted regardless of
the resolution.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/comedi/drivers/amplc_pci230.c