]> git.baikalelectronics.ru Git - kernel.git/commit
thermal: generic-adc: Fix adc to temp interpolation
authorBjorn Andersson <bjorn.andersson@linaro.org>
Mon, 24 Dec 2018 07:26:44 +0000 (23:26 -0800)
committerEduardo Valentin <edubezval@gmail.com>
Wed, 2 Jan 2019 12:47:23 +0000 (04:47 -0800)
commitfd4b894b4a88faf50ad0d32e126d24716b0d2fa9
tree52ee024a436534a9144f29b6318252ee5970fe8d
parent87cc74f10d286312bde6b67fdbf24d7b1fac3c14
thermal: generic-adc: Fix adc to temp interpolation

First correct the edge case to return the last element if we're
outside the range, rather than at the last element, so that
interpolation is not omitted for points between the two last entries in
the table.

Then correct the formula to perform linear interpolation based the two
points surrounding the read ADC value. The indices for temp are kept as
"hi" and "lo" to pair with the adc indices, but there's no requirement
that the temperature is provided in descendent order. mult_frac() is
used to prevent issues with overflowing the int.

Cc: Laxman Dewangan <ldewangan@nvidia.com>
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
drivers/thermal/thermal-generic-adc.c