[PATCH] Fix s3c2410_ts FIFO allocation

Nelson Castillo nelsoneci at gmail.com
Mon Dec 8 23:30:55 CET 2008


When I added the FIFO improving the interrupts handlers I introduced a bug.
The FIFO is allocated after the interrupts are requested. This makes the kernel
crash if the touchscreen generates activity before the allocation takes place.
This patch fixes the bug. I reproduced it and tested the fix in a GTA02.

- Fix bug
- Fix a typo

Reported-by: Andy Green Andy Green <andy at openmoko.com>
Signed-off-by: Nelson Castillo <nelsoneci at gmail.com>
---

 0 files changed, 0 insertions(+), 0 deletions(-)

diff --git a/drivers/input/touchscreen/s3c2410_ts.c b/drivers/input/touchscreen/s3c2410_ts.c
index 8e6bc0a..4159ada 100644
--- a/drivers/input/touchscreen/s3c2410_ts.c
+++ b/drivers/input/touchscreen/s3c2410_ts.c
@@ -427,6 +427,11 @@ static int __init s3c2410ts_probe(struct platform_device *pdev)
 	ts.dev->id.product = 0xBEEF;
 	ts.dev->id.version = S3C2410TSVERSION;
 	ts.state = TS_STATE_STANDBY;
+	ts.event_fifo = kfifo_alloc(TS_EVENT_FIFO_SIZE, GFP_KERNEL, NULL);
+	if (IS_ERR(ts.event_fifo)) {
+		ret = -EIO;
+		goto bail2;
+	}
 
 	/* create the filter chain set up for the 2 coordinates we produce */
 	ret = ts_filter_create_chain(
@@ -459,26 +464,17 @@ static int __init s3c2410ts_probe(struct platform_device *pdev)
 		goto bail4;
 	}
 
-	ts.event_fifo = kfifo_alloc(TS_EVENT_FIFO_SIZE, GFP_KERNEL, NULL);
-
-	if (IS_ERR(ts.event_fifo)) {
-		ret = -EIO;
-		goto bail5;
-	}
-
 	dev_info(&pdev->dev, "successfully loaded\n");
 
 	/* All went ok, so register to the input system */
 	rc = input_register_device(ts.dev);
 	if (rc) {
 		ret = -EIO;
-		goto bail6;
+		goto bail5;
 	}
 
 	return 0;
 
-bail6:
-	kfifo_free(ts.event_fifo);
 bail5:
 	free_irq(IRQ_TC, ts.dev);
 	free_irq(IRQ_ADC, ts.dev);
@@ -489,7 +485,8 @@ bail4:
 	disable_irq(IRQ_ADC);
 bail3:
 	ts_filter_destroy_chain(ts.tsf);
-
+	kfifo_free(ts.event_fifo);
+bail2:
 	input_unregister_device(ts.dev);
 bail1:
 	iounmap(base_addr);
diff --git a/include/linux/ts_filter.h b/include/linux/ts_filter.h
index bfb8a22..715f1ba 100644
--- a/include/linux/ts_filter.h
+++ b/include/linux/ts_filter.h
@@ -8,7 +8,7 @@
  */
 
 #define MAX_TS_FILTER_CHAIN		4  /* max filters you can chain up */
-#define MAX_TS_FILTER_COORDS		3  /* Y, Y and Z (pressure) */
+#define MAX_TS_FILTER_COORDS		3  /* X, Y and Z (pressure) */
 
 struct ts_filter;
 




More information about the openmoko-kernel mailing list