Thread (33 messages) 33 messages, 5 authors, 2021-02-18

[thermal: thermal/next] iio: adc: qcom-vadc-common: use fixp_linear_interpolate

From: thermal-bot for Dmitry Baryshkov <hidden>
Date: 2021-02-18 20:43:11
Subsystem: arm/qualcomm mailing list, iio subsystem and drivers, the rest · Maintainers: Jonathan Cameron, Linus Torvalds

The following commit has been merged into the thermal/next branch of thermal:

Commit-ID:     e2621acd6d9af5b3d5584ddf0fd7994472d6199e
Gitweb:        https://git.kernel.org/pub/scm/linux/kernel/git/thermal/linux.git//e2621acd6d9af5b3d5584ddf0fd7994472d6199e
Author:        Dmitry Baryshkov [off-list ref]
AuthorDate:    Fri, 04 Dec 2020 05:54:58 +03:00
Committer:     Jonathan Cameron [off-list ref]
CommitterDate: Sat, 16 Jan 2021 18:19:00 

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 <redacted>
Link: https://lore.kernel.org/r/20201204025509.1075506-5-dmitry.baryshkov@linaro.org (local)
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
---
 drivers/iio/adc/qcom-vadc-common.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/iio/adc/qcom-vadc-common.c b/drivers/iio/adc/qcom-vadc-common.c
index d11f334..40d77b3 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>
@@ -368,10 +369,9 @@ 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;
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help