@@ -68,11 +68,12 @@ static void tsc2007_read_values(struct tsc2007 *tsc, struct ts_event *tc)
u32 tsc2007_calculate_resistance(struct tsc2007 *tsc, struct ts_event *tc)
{
- u32 rt = 0;
+ u64 rt = 0;
/* range filtering */
- if (tc->x == MAX_12BIT)
+ if (tc->x == MAX_12BIT) {
tc->x = 0;
+ }
if (likely(tc->x && tc->z1)) {
/* compute touch resistance using equation #1 */
@@ -83,7 +84,9 @@ u32 tsc2007_calculate_resistance(struct tsc2007 *tsc, struct ts_event *tc)
rt = (rt + 2047) >> 12;
}
- return rt;
+ if (rt > U32_MAX)
+ return U32_MAX;
+ return (u32) rt;
}
bool tsc2007_is_pen_down(struct tsc2007 *ts)