aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Baryshkov <dmitry.baryshkov@linaro.org>2020-06-23 00:13:09 +0300
committerDmitry Baryshkov <dmitry.baryshkov@linaro.org>2020-06-23 00:35:53 +0300
commit3727ff90edf6bb93025129f804bd2c97d8d161fa (patch)
tree4dd7e0f711d95595ca0bf2f9d302667b36434017
parentfc2bb6c726df02973748d1aa46cb22622287bc79 (diff)
iio: adc: qcom-vadc-common: use fixp_linear_interpolate
Use new function fixp_linear_interpolate() instead of hand-coding the linar interpolation. Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
-rw-r--r--drivers/iio/adc/qcom-vadc-common.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/drivers/iio/adc/qcom-vadc-common.c b/drivers/iio/adc/qcom-vadc-common.c
index ffa578ce76db..aab1ef1c8da4 100644
--- a/drivers/iio/adc/qcom-vadc-common.c
+++ b/drivers/iio/adc/qcom-vadc-common.c
@@ -2,6 +2,7 @@
#include <linux/bug.h>
#include <linux/kernel.h>
#include <linux/bitops.h>
+#include <linux/fixp-arith.h>
#include <linux/math64.h>
#include <linux/log2.h>
#include <linux/err.h>
@@ -167,10 +168,8 @@ static int qcom_vadc_map_voltage_temp(const struct vadc_map_pt *pts,
} else {
/* result is between search_index and search_index-1 */
/* interpolate linearly */
- *output = (((s32)((pts[i].y - pts[i - 1].y) *
- (input - pts[i - 1].x)) /
- (pts[i].x - pts[i - 1].x)) +
- pts[i - 1].y);
+ *output = fixp_linear_interpolate(pts[i - 1].x, pts[i - 1].y,
+ pts[i].x, pts[i].y, input);
}
return 0;