diff options
author | Vadim Zaliva <lord@crocodile.org> | 2010-03-11 02:41:00 -0500 |
---|---|---|
committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2010-03-11 03:00:56 -0500 |
commit | 04b4b88cca0ebe3813b4b6f014fb6a0db380b137 (patch) | |
tree | e433748561def86a9568b3adb988b5a187e79ee5 | |
parent | 4eb6f91b95e7618eae0103b6cba7c7f01f9d40f3 (diff) |
Input: appletouch - fix integer overflow issue
When reading data from Geyser 2 touchpads used on post Oct 2005 Apple
PowerBooks the driver was casting X and Y coordinates values to
'signed char'. Testing on one of such PowerBooks I have noticed that
touchpad always generates positive values, but some of them are greater
that 127, and thus, when cast to 'signed char' being interpreted as
a negative.
Such bigger values have been observed infrequently, closer to the
edges of a touchpad, so the problem was not very visible.
Nevertheless, the patch would potentially improve touchpad
driver accuracy.
Signed-off-by: Vadim Zaliva <lord@crocodile.org>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
-rw-r--r-- | drivers/input/mouse/appletouch.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/drivers/input/mouse/appletouch.c b/drivers/input/mouse/appletouch.c index 908b5b44052f..53ec7ddd1826 100644 --- a/drivers/input/mouse/appletouch.c +++ b/drivers/input/mouse/appletouch.c | |||
@@ -205,8 +205,8 @@ struct atp { | |||
205 | bool overflow_warned; | 205 | bool overflow_warned; |
206 | int x_old; /* last reported x/y, */ | 206 | int x_old; /* last reported x/y, */ |
207 | int y_old; /* used for smoothing */ | 207 | int y_old; /* used for smoothing */ |
208 | signed char xy_cur[ATP_XSENSORS + ATP_YSENSORS]; | 208 | u8 xy_cur[ATP_XSENSORS + ATP_YSENSORS]; |
209 | signed char xy_old[ATP_XSENSORS + ATP_YSENSORS]; | 209 | u8 xy_old[ATP_XSENSORS + ATP_YSENSORS]; |
210 | int xy_acc[ATP_XSENSORS + ATP_YSENSORS]; | 210 | int xy_acc[ATP_XSENSORS + ATP_YSENSORS]; |
211 | int idlecount; /* number of empty packets */ | 211 | int idlecount; /* number of empty packets */ |
212 | struct work_struct work; | 212 | struct work_struct work; |
@@ -531,7 +531,7 @@ static void atp_complete_geyser_1_2(struct urb *urb) | |||
531 | 531 | ||
532 | for (i = 0; i < ATP_XSENSORS + ATP_YSENSORS; i++) { | 532 | for (i = 0; i < ATP_XSENSORS + ATP_YSENSORS; i++) { |
533 | /* accumulate the change */ | 533 | /* accumulate the change */ |
534 | signed char change = dev->xy_old[i] - dev->xy_cur[i]; | 534 | int change = dev->xy_old[i] - dev->xy_cur[i]; |
535 | dev->xy_acc[i] -= change; | 535 | dev->xy_acc[i] -= change; |
536 | 536 | ||
537 | /* prevent down drifting */ | 537 | /* prevent down drifting */ |