[ar71xx] preliminary support for the Ubiquiti RouterStation Pro
[openwrt.git] / target / linux / s3c24xx / patches-2.6.24 / 1210-fix-touchscreen-meddling-divde.patch.patch
1 From e0dc30dfda233d4ebe6f88cd1162e5952fc69027 Mon Sep 17 00:00:00 2001
2 From: Andy Green <andy@openmoko.com>
3 Date: Wed, 2 Jul 2008 22:43:38 +0100
4 Subject: [PATCH] fix-touchscreen-meddling-divde.patch
5 Reported-by: Holger Freyther <zecke@openmoko.org>
6
7 length can be zero... blowing a divide by zero exception...
8 which somehow I don't get (?) Anyway the code is wrong and
9 this should fix it.
10
11 Signed-off-by: Andy Green <andy@openmoko.com>
12 ---
13 drivers/input/touchscreen/s3c2410_ts.c | 12 +++++++++---
14 1 files changed, 9 insertions(+), 3 deletions(-)
15
16 diff --git a/drivers/input/touchscreen/s3c2410_ts.c b/drivers/input/touchscreen/s3c2410_ts.c
17 index 83e7aff..9fb95c1 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)
21 unsigned long x;
22 unsigned long y;
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;
26 + int scaled_avg_x;
27 + int scaled_avg_y;
28
29 x = readl(base_addr + S3C2410_ADCDAT0) & S3C2410_ADCDAT0_XPDATA_MASK;
30 y = readl(base_addr + S3C2410_ADCDAT1) & S3C2410_ADCDAT1_YPDATA_MASK;
31
32 + if (!length)
33 + goto store_sample;
34 +
35 + scaled_avg_x = ts.raw_running_avg.x / length;
36 + scaled_avg_y = ts.raw_running_avg.y / length;
37 +
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)
42 else
43 ts.flag_previous_exceeded_threshold = 1;
44
45 - /* accepted */
46 +store_sample:
47 ts.xp += x;
48 ts.yp += y;
49 ts.count++;
50 --
51 1.5.6.5
52
This page took 0.046996 seconds and 5 git commands to generate.