1 From 9bdb2dbc9725d7f2ba23566303d5abe0504beb83 Mon Sep 17 00:00:00 2001
2 From: Andy Green <andy@openmoko.com>
3 Date: Fri, 25 Jul 2008 23:06:16 +0100
4 Subject: [PATCH] fix-touchscreen-meddling-divde.patch
5 Reported-by: Holger Freyther <zecke@openmoko.org>
7 length can be zero... blowing a divide by zero exception...
8 which somehow I don't get (?) Anyway the code is wrong and
11 Signed-off-by: Andy Green <andy@openmoko.com>
13 drivers/input/touchscreen/s3c2410_ts.c | 12 +++++++++---
14 1 files changed, 9 insertions(+), 3 deletions(-)
16 diff --git a/drivers/input/touchscreen/s3c2410_ts.c b/drivers/input/touchscreen/s3c2410_ts.c
17 index b1ba73d..5bc347f 100644
18 --- a/drivers/input/touchscreen/s3c2410_ts.c
19 +++ b/drivers/input/touchscreen/s3c2410_ts.c
20 @@ -226,12 +226,18 @@ static irqreturn_t stylus_action(int irq, void *dev_id)
23 int length = (ts.head_raw_fifo - ts.tail_raw_fifo) & (ts.extent - 1);
24 - int scaled_avg_x = ts.raw_running_avg.x / length;
25 - int scaled_avg_y = ts.raw_running_avg.y / length;
29 x = readl(base_addr + S3C2410_ADCDAT0) & S3C2410_ADCDAT0_XPDATA_MASK;
30 y = readl(base_addr + S3C2410_ADCDAT1) & S3C2410_ADCDAT1_YPDATA_MASK;
35 + scaled_avg_x = ts.raw_running_avg.x / length;
36 + scaled_avg_y = ts.raw_running_avg.y / length;
38 /* we appear to accept every sample into both the running average FIFO
39 * and the summing average. BUT, if the last sample crossed a
40 * machine-set threshold, each time we do a beauty contest
41 @@ -280,7 +286,7 @@ static irqreturn_t stylus_action(int irq, void *dev_id)
43 ts.flag_previous_exceeded_threshold = 1;