• Ian Abbott's avatar
    staging: comedi: amplc_pci230: simplify pci230_ai_read() · 66a462ba
    Ian Abbott authored
    `pci230_ai_read()` reads a sample from the ADC data register and
    converts it to a comedi sample value.  The AI sample may have 12 or 16
    bits of resolution, depending on the board type, but 12-bit sample
    values are in bits 15 to 4 of the register.  The hardware value is
    signed, 2's complement if set to a bipolar mode, or unsigned, straight
    binary if set to a unipolar mode.  To convert to a Comedi sample value
    it may need shifting right by 4 bits, and the top bit of the sample
    value may need to be toggled.
    
    Simplify the existing code by doing the 2's complement to straight
    binary conversion before the shift.  That way, it is always bit 15 that
    is inverted regardless of the resolution.
    Signed-off-by: default avatarIan Abbott <abbotti@mev.co.uk>
    Reviewed-by: default avatarH Hartley Sweeten <hsweeten@visionengravers.com>
    Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    66a462ba
amplc_pci230.c 81.3 KB