• Lars-Peter Clausen's avatar
    staging:iio:ad7192: Report offset and scale for temperature channel · 4fcbcf95
    Lars-Peter Clausen authored
    The temperature channel reports values in degree Kelvin with sensitivity of 5630
    codes per degree. If the chip is configured in bipolar mode there is an
    additional binary offset of 0x800000 and the sensitivity is divided by two.
    
    Currently the driver does the mapping from the raw value to degree Celsius when
    doing a manual conversion. This has several disadvantages, the major one being
    that it does not work for buffered mode, also by doing the division by the
    sensitivity in the driver the precession of the reported value is needlessly
    reduced.
    
    Furthermore the current calculation only works in bipolar mode and the current
    scale is of by a factor of 1000.
    
    This patch modifies the driver to report correct offset and scale values in
    both unipolar and bipolar mode and to report the raw temperature value
    for manual conversions.
    Signed-off-by: default avatarLars-Peter Clausen <lars@metafoo.de>
    Signed-off-by: default avatarJonathan Cameron <jic23@kernel.org>
    4fcbcf95
ad7192.c 28.4 KB