iio: adc: qcom-vadc-common: use fixp_linear_interpolate

Use new function fixp_linear_interpolate() instead of hand-coding the
linear interpolation.

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Link: https://lore.kernel.org/r/20201204025509.1075506-5-dmitry.baryshkov@linaro.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
This commit is contained in:
Dmitry Baryshkov 2020-12-04 05:54:58 +03:00 committed by Jonathan Cameron
parent c7ba98fc40
commit e2621acd6d
1 changed files with 4 additions and 4 deletions

View File

@ -2,6 +2,7 @@
#include <linux/bug.h> #include <linux/bug.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/bitops.h> #include <linux/bitops.h>
#include <linux/fixp-arith.h>
#include <linux/math64.h> #include <linux/math64.h>
#include <linux/log2.h> #include <linux/log2.h>
#include <linux/err.h> #include <linux/err.h>
@ -368,10 +369,9 @@ static int qcom_vadc_map_voltage_temp(const struct vadc_map_pt *pts,
} else { } else {
/* result is between search_index and search_index-1 */ /* result is between search_index and search_index-1 */
/* interpolate linearly */ /* interpolate linearly */
*output = (((s32)((pts[i].y - pts[i - 1].y) * *output = fixp_linear_interpolate(pts[i - 1].x, pts[i - 1].y,
(input - pts[i - 1].x)) / pts[i].x, pts[i].y,
(pts[i].x - pts[i - 1].x)) + input);
pts[i - 1].y);
} }
return 0; return 0;