Skip to content

Commit e2621ac

Browse files
lumagjic23
authored andcommitted
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>
1 parent c7ba98f commit e2621ac

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

drivers/iio/adc/qcom-vadc-common.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#include <linux/bug.h>
33
#include <linux/kernel.h>
44
#include <linux/bitops.h>
5+
#include <linux/fixp-arith.h>
56
#include <linux/math64.h>
67
#include <linux/log2.h>
78
#include <linux/err.h>
@@ -368,10 +369,9 @@ static int qcom_vadc_map_voltage_temp(const struct vadc_map_pt *pts,
368369
} else {
369370
/* result is between search_index and search_index-1 */
370371
/* interpolate linearly */
371-
*output = (((s32)((pts[i].y - pts[i - 1].y) *
372-
(input - pts[i - 1].x)) /
373-
(pts[i].x - pts[i - 1].x)) +
374-
pts[i - 1].y);
372+
*output = fixp_linear_interpolate(pts[i - 1].x, pts[i - 1].y,
373+
pts[i].x, pts[i].y,
374+
input);
375375
}
376376

377377
return 0;

0 commit comments

Comments
 (0)