X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;ds=inline;f=board%2Ftrab%2Ftsc2000.c;h=f13a5a9dc0251d4173472381a1315e5fd448a9fd;hb=3c92217732edfc0016c3cbdc828471d013d23a36;hp=382a85b359300146d456f37f88c10dba6d5d5a40;hpb=f73e73ba0e422e6f79030d77286dd57becaee16f;p=u-boot diff --git a/board/trab/tsc2000.c b/board/trab/tsc2000.c index 382a85b359..f13a5a9dc0 100644 --- a/board/trab/tsc2000.c +++ b/board/trab/tsc2000.c @@ -27,6 +27,7 @@ #include #include +#include #include "tsc2000.h" #include "Pt1000_temp_data.h" @@ -332,6 +333,7 @@ void tsc2000_reg_init (void) int tsc2000_interpolate(long value, long data[][2], long *result) { int i; + unsigned long long val; /* the data is sorted and the first element is upper * limit so we can easily check for out-of-band values @@ -347,10 +349,10 @@ int tsc2000_interpolate(long value, long data[][2], long *result) result in 'long long'. */ - *result = data[i-1][1] + - ((unsigned long long)(data[i][1] - data[i-1][1]) - * (unsigned long long)(value - data[i-1][0])) - / (data[i][0] - data[i-1][0]); + val = ((unsigned long long)(data[i][1] - data[i-1][1]) + * (unsigned long long)(value - data[i-1][0])); + do_div(val, (data[i][0] - data[i-1][0])); + *result = data[i-1][1] + val; return 0; }