public inbox for linux-omap@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Convert touchscreen to input_allocate_device
@ 2005-12-04 15:52 Dirk Behme
  0 siblings, 0 replies; 12+ messages in thread
From: Dirk Behme @ 2005-12-04 15:52 UTC (permalink / raw)
  To: linux-omap-open-source

[-- Attachment #1: Type: text/plain, Size: 427 bytes --]

ARM: OMAP: Convert touchscreen to input_allocate_device() to remove:

input: device omap_ts is statically allocated, will not register
Please convert to input_allocate_device() or contact dtor_core@ameritech.net

ARM: OMAP: Check in omap_ts_handler() if timer is still running. Delete
it if necessary. Else we will get Oops "kernel BUG at
include/linux/timer.h:83!"

Signed-off-by: Dirk Behme <dirk.behme_at_de.bosch.com>






[-- Attachment #2: touchscreen_input_allocate_device.patch --]
[-- Type: text/plain, Size: 3799 bytes --]

--- ./drivers/input/touchscreen/omap/omap_ts.c_orig	2005-12-02 17:41:07.000000000 +0100
+++ ./drivers/input/touchscreen/omap/omap_ts.c	2005-12-02 18:11:32.000000000 +0100
@@ -65,10 +65,10 @@ static int omap_ts_read(void)
 
 	ts_omap.dev->read(data);
 
-	input_report_abs(&(ts_omap.inputdevice), ABS_X, data[0]);
-	input_report_abs(&(ts_omap.inputdevice), ABS_Y, data[1]);
-	input_report_abs(&(ts_omap.inputdevice), ABS_PRESSURE, data[2]);
-	input_sync(&(ts_omap.inputdevice));
+	input_report_abs(ts_omap.inputdevice, ABS_X, data[0]);
+	input_report_abs(ts_omap.inputdevice, ABS_Y, data[1]);
+	input_report_abs(ts_omap.inputdevice, ABS_PRESSURE, data[2]);
+	input_sync(ts_omap.inputdevice);
 
 	DEBUG_TS("omap_ts_read: read x=%d,y=%d,p=%d\n", data[0], data[1],
 		 data[2]);
@@ -85,7 +85,7 @@ static void omap_ts_timer(unsigned long 
 	if (!ts_omap.dev->penup()) {
 		if (!ts_omap.touched) {
 			DEBUG_TS("omap_ts_timer: pen down\n");
-			input_report_key(&(ts_omap.inputdevice), BTN_TOUCH, 1);
+			input_report_key(ts_omap.inputdevice, BTN_TOUCH, 1);
 		}
 		ts_omap.touched = 1;
 		omap_ts_read();
@@ -95,12 +95,12 @@ static void omap_ts_timer(unsigned long 
 		if (ts_omap.touched) {
 			DEBUG_TS("omap_ts_timer: pen up\n");
 			ts_omap.touched = 0;
-			input_report_abs(&(ts_omap.inputdevice), ABS_X, 0);
-			input_report_abs(&(ts_omap.inputdevice), ABS_Y, 0);
-			input_report_abs(&(ts_omap.inputdevice), ABS_PRESSURE,
+			input_report_abs(ts_omap.inputdevice, ABS_X, 0);
+			input_report_abs(ts_omap.inputdevice, ABS_Y, 0);
+			input_report_abs(ts_omap.inputdevice, ABS_PRESSURE,
 					 0);
-			input_sync(&(ts_omap.inputdevice));
-			input_report_key(&(ts_omap.inputdevice), BTN_TOUCH, 0);
+			input_sync(ts_omap.inputdevice);
+			input_report_key(ts_omap.inputdevice, BTN_TOUCH, 0);
 		}
 		if (!ts_omap.irq_enabled) {
 			ts_omap.irq_enabled = 1;
@@ -119,7 +119,10 @@ static irqreturn_t omap_ts_handler(int i
 		ts_omap.irq_enabled = 0;
 		disable_irq(irq);
 	}
-	// restart acquire
+	// check for still pending timer, delete it if neccessary
+        if(timer_pending(&(ts_omap.ts_timer)))
+		del_timer(&(ts_omap.ts_timer));
+        // restart acquire
 	ts_omap.ts_timer.expires = jiffies + HZ / 100;
 	add_timer(&(ts_omap.ts_timer));
 
@@ -168,14 +171,14 @@ static int __init omap_ts_probe(struct p
 		return -EINVAL;
 	}
 
-	init_input_dev(&(ts_omap.inputdevice));
-	ts_omap.inputdevice.name = OMAP_TS_NAME;
-	ts_omap.inputdevice.dev = &pdev->dev;
-	ts_omap.inputdevice.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
-	ts_omap.inputdevice.keybit[LONG(BTN_TOUCH)] |= BIT(BTN_TOUCH);
-	ts_omap.inputdevice.absbit[0] =
+	ts_omap.inputdevice = input_allocate_device();
+	ts_omap.inputdevice->name = OMAP_TS_NAME;
+	ts_omap.inputdevice->dev = &pdev->dev;
+	ts_omap.inputdevice->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
+	ts_omap.inputdevice->keybit[LONG(BTN_TOUCH)] |= BIT(BTN_TOUCH);
+	ts_omap.inputdevice->absbit[0] =
 	    BIT(ABS_X) | BIT(ABS_Y) | BIT(ABS_PRESSURE);
-	input_register_device(&(ts_omap.inputdevice));
+	input_register_device(ts_omap.inputdevice);
 
 	ts_omap.dev->enable();
 
@@ -187,7 +190,7 @@ static int __init omap_ts_probe(struct p
 static int omap_ts_remove(struct platform_device *pdev)
 {
 	ts_omap.dev->disable();
-	input_unregister_device(&ts_omap.inputdevice);
+	input_unregister_device(ts_omap.inputdevice);
 	if (ts_omap.irq != -1)
 		free_irq(ts_omap.irq, &ts_omap);
 
--- ./drivers/input/touchscreen/omap/omap_ts.h_orig	2005-12-02 17:42:30.000000000 +0100
+++ ./drivers/input/touchscreen/omap/omap_ts.h	2005-12-02 17:43:05.000000000 +0100
@@ -42,7 +42,7 @@ struct ts_device {
 };
 
 struct omap_ts_t{
-	struct input_dev inputdevice;
+	struct input_dev * inputdevice;
 	struct timer_list ts_timer;      // Timer for triggering acquisitions
 	int touched;
 	int irq;






[-- Attachment #3: Type: text/plain, Size: 0 bytes --]



^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH] Convert touchscreen to input_allocate_device
  2006-01-03 19:13   ` Pending patches mostly pushed, please check Tony Lindgren
@ 2006-01-06 19:37     ` Dirk Behme
  2006-01-14  0:18       ` Tony Lindgren
  0 siblings, 1 reply; 12+ messages in thread
From: Dirk Behme @ 2006-01-06 19:37 UTC (permalink / raw)
  To: Tony Lindgren; +Cc: linux-omap-open-source

[-- Attachment #1: Type: text/plain, Size: 397 bytes --]

Tony Lindgren wrote:
> Dirk, I've only pushed Todd's timer fix below like you suggested. Can you please
> update your patch?

ARM: OMAP: Convert touchscreen to input_allocate_device() to remove:

input: device omap_ts is statically allocated, will not register
Please convert to input_allocate_device() or contact dtor_core@ameritech.net

Signed-off-by: Dirk Behme <dirk.behme_at_de.bosch.com>




[-- Attachment #2: touchscreen_input_allocate_device.patch --]
[-- Type: text/plain, Size: 3403 bytes --]

--- ./drivers/input/touchscreen/omap/omap_ts.c_orig	2006-01-06 16:43:40.000000000 +0100
+++ ./drivers/input/touchscreen/omap/omap_ts.c	2006-01-06 18:48:39.754015208 +0100
@@ -65,10 +65,10 @@ static int omap_ts_read(void)
 
 	ts_omap.dev->read(data);
 
-	input_report_abs(&(ts_omap.inputdevice), ABS_X, data[0]);
-	input_report_abs(&(ts_omap.inputdevice), ABS_Y, data[1]);
-	input_report_abs(&(ts_omap.inputdevice), ABS_PRESSURE, data[2]);
-	input_sync(&(ts_omap.inputdevice));
+	input_report_abs(ts_omap.inputdevice, ABS_X, data[0]);
+	input_report_abs(ts_omap.inputdevice, ABS_Y, data[1]);
+	input_report_abs(ts_omap.inputdevice, ABS_PRESSURE, data[2]);
+	input_sync(ts_omap.inputdevice);
 
 	DEBUG_TS("omap_ts_read: read x=%d,y=%d,p=%d\n", data[0], data[1],
 		 data[2]);
@@ -85,7 +85,7 @@ static void omap_ts_timer(unsigned long 
 	if (!ts_omap.dev->penup()) {
 		if (!ts_omap.touched) {
 			DEBUG_TS("omap_ts_timer: pen down\n");
-			input_report_key(&(ts_omap.inputdevice), BTN_TOUCH, 1);
+			input_report_key(ts_omap.inputdevice, BTN_TOUCH, 1);
 		}
 		ts_omap.touched = 1;
 		omap_ts_read();
@@ -95,12 +95,12 @@ static void omap_ts_timer(unsigned long 
 		if (ts_omap.touched) {
 			DEBUG_TS("omap_ts_timer: pen up\n");
 			ts_omap.touched = 0;
-			input_report_abs(&(ts_omap.inputdevice), ABS_X, 0);
-			input_report_abs(&(ts_omap.inputdevice), ABS_Y, 0);
-			input_report_abs(&(ts_omap.inputdevice), ABS_PRESSURE,
+			input_report_abs(ts_omap.inputdevice, ABS_X, 0);
+			input_report_abs(ts_omap.inputdevice, ABS_Y, 0);
+			input_report_abs(ts_omap.inputdevice, ABS_PRESSURE,
 					 0);
-			input_sync(&(ts_omap.inputdevice));
-			input_report_key(&(ts_omap.inputdevice), BTN_TOUCH, 0);
+			input_sync(ts_omap.inputdevice);
+			input_report_key(ts_omap.inputdevice, BTN_TOUCH, 0);
 		}
 		if (!ts_omap.irq_enabled) {
 			ts_omap.irq_enabled = 1;
@@ -167,14 +167,14 @@ static int __init omap_ts_probe(struct p
 		return -EINVAL;
 	}
 
-	init_input_dev(&(ts_omap.inputdevice));
-	ts_omap.inputdevice.name = OMAP_TS_NAME;
-	ts_omap.inputdevice.dev = &pdev->dev;
-	ts_omap.inputdevice.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
-	ts_omap.inputdevice.keybit[LONG(BTN_TOUCH)] |= BIT(BTN_TOUCH);
-	ts_omap.inputdevice.absbit[0] =
+	ts_omap.inputdevice = input_allocate_device();
+	ts_omap.inputdevice->name = OMAP_TS_NAME;
+	ts_omap.inputdevice->dev = &pdev->dev;
+	ts_omap.inputdevice->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
+	ts_omap.inputdevice->keybit[LONG(BTN_TOUCH)] |= BIT(BTN_TOUCH);
+	ts_omap.inputdevice->absbit[0] =
 	    BIT(ABS_X) | BIT(ABS_Y) | BIT(ABS_PRESSURE);
-	input_register_device(&(ts_omap.inputdevice));
+	input_register_device(ts_omap.inputdevice);
 
 	ts_omap.dev->enable();
 
@@ -186,7 +186,7 @@ static int __init omap_ts_probe(struct p
 static int omap_ts_remove(struct platform_device *pdev)
 {
 	ts_omap.dev->disable();
-	input_unregister_device(&ts_omap.inputdevice);
+	input_unregister_device(ts_omap.inputdevice);
 	if (ts_omap.irq != -1)
 		free_irq(ts_omap.irq, &ts_omap);
 
--- ./drivers/input/touchscreen/omap/omap_ts.h_orig	2006-01-06 16:43:40.000000000 +0100
+++ ./drivers/input/touchscreen/omap/omap_ts.h	2006-01-06 18:48:39.756014904 +0100
@@ -42,7 +42,7 @@ struct ts_device {
 };
 
 struct omap_ts_t{
-	struct input_dev inputdevice;
+	struct input_dev * inputdevice;
 	struct timer_list ts_timer;      // Timer for triggering acquisitions
 	int touched;
 	int irq;


[-- Attachment #3: Type: text/plain, Size: 0 bytes --]



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] Convert touchscreen to input_allocate_device
  2006-01-06 19:37     ` [PATCH] Convert touchscreen to input_allocate_device Dirk Behme
@ 2006-01-14  0:18       ` Tony Lindgren
  0 siblings, 0 replies; 12+ messages in thread
From: Tony Lindgren @ 2006-01-14  0:18 UTC (permalink / raw)
  To: Dirk Behme; +Cc: linux-omap-open-source

* Dirk Behme <dirk.behme@de.bosch.com> [060106 11:36]:
> Tony Lindgren wrote:
> >Dirk, I've only pushed Todd's timer fix below like you suggested. Can you 
> >please
> >update your patch?
> 
> ARM: OMAP: Convert touchscreen to input_allocate_device() to remove:
> 
> input: device omap_ts is statically allocated, will not register
> Please convert to input_allocate_device() or contact dtor_core@ameritech.net

Pushing this one today, thanks.

Tony

^ permalink raw reply	[flat|nested] 12+ messages in thread

* RE: [PATCH] Convert touchscreen to input_allocate_device
@ 2006-01-16 11:59 Mikko.Soikkala
  2006-01-16 18:15 ` Dirk Behme
  0 siblings, 1 reply; 12+ messages in thread
From: Mikko.Soikkala @ 2006-01-16 11:59 UTC (permalink / raw)
  To: tony, dirk.behme; +Cc: linux-omap-open-source

Hi

Shouldn't there be a check after input_allocate_device() if the
allocation fails? At least other touchscreen drivers seem to return
-ENOMEM in this case.

Mikko

-----Original Message-----
From: linux-omap-open-source-bounces@linux.omap.com
[mailto:linux-omap-open-source-bounces@linux.omap.com] On Behalf Of Tony
Lindgren
Sent: 14. tammikuuta 2006 02:18
To: Dirk Behme
Cc: linux-omap-open-source@linux.omap.com
Subject: Re: [PATCH] Convert touchscreen to input_allocate_device

* Dirk Behme <dirk.behme@de.bosch.com> [060106 11:36]:
> Tony Lindgren wrote:
> >Dirk, I've only pushed Todd's timer fix below like you suggested. Can
you 
> >please
> >update your patch?
> 
> ARM: OMAP: Convert touchscreen to input_allocate_device() to remove:
> 
> input: device omap_ts is statically allocated, will not register
> Please convert to input_allocate_device() or contact
dtor_core@ameritech.net

Pushing this one today, thanks.

Tony
_______________________________________________
Linux-omap-open-source mailing list
Linux-omap-open-source@linux.omap.com
http://linux.omap.com/mailman/listinfo/linux-omap-open-source

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] Convert touchscreen to input_allocate_device
  2006-01-16 11:59 [PATCH] Convert touchscreen to input_allocate_device Mikko.Soikkala
@ 2006-01-16 18:15 ` Dirk Behme
  0 siblings, 0 replies; 12+ messages in thread
From: Dirk Behme @ 2006-01-16 18:15 UTC (permalink / raw)
  To: Mikko.Soikkala; +Cc: linux-omap-open-source

Mikko.Soikkala@Tietoenator.com wrote:
> Hi
> 
> Shouldn't there be a check after input_allocate_device() if the
> allocation fails? At least other touchscreen drivers seem to return
> -ENOMEM in this case.

Sounds good to me. Can you send a patch?

Thanks

Dirk

^ permalink raw reply	[flat|nested] 12+ messages in thread

* RE: [PATCH] Convert touchscreen to input_allocate_device
@ 2006-01-17 13:24 Mikko.Soikkala
  2006-01-17 15:12 ` Komal Shah
  0 siblings, 1 reply; 12+ messages in thread
From: Mikko.Soikkala @ 2006-01-17 13:24 UTC (permalink / raw)
  To: dirk.behme; +Cc: linux-omap-open-source

> -----Original Message-----
> From: Dirk Behme [mailto:dirk.behme@de.bosch.com]
> 
> Mikko.Soikkala@Tietoenator.com wrote:
> > Hi
> >
> > Shouldn't there be a check after input_allocate_device() if the
> > allocation fails? At least other touchscreen drivers seem to return
> > -ENOMEM in this case.
> 
> Sounds good to me. Can you send a patch?

I'm still learning how to create and submit patches, but hopefully this
does the trick.

Mikko

--

diff -Naur linux-2.6.15-omap2/drivers/input/touchscreen/omap/omap_ts.c
linux-2.6.15-omap2-tsfix/drivers/input/touchscreen/omap/omap_ts.c
--- linux-2.6.15-omap2/drivers/input/touchscreen/omap/omap_ts.c
2006-01-17 14:39:49.000000000 +0200
+++ linux-2.6.15-omap2-tsfix/drivers/input/touchscreen/omap/omap_ts.c
2006-01-17 14:47:48.000000000 +0200
@@ -168,6 +168,9 @@
 	}
 
 	ts_omap.inputdevice = input_allocate_device();
+	if (!ts_omap.inputdevice)
+		return -ENOMEM;
+
 	ts_omap.inputdevice->name = OMAP_TS_NAME;
 	ts_omap.inputdevice->dev = &pdev->dev;
 	ts_omap.inputdevice->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);

^ permalink raw reply	[flat|nested] 12+ messages in thread

* RE: [PATCH] Convert touchscreen to input_allocate_device
  2006-01-17 13:24 Mikko.Soikkala
@ 2006-01-17 15:12 ` Komal Shah
  0 siblings, 0 replies; 12+ messages in thread
From: Komal Shah @ 2006-01-17 15:12 UTC (permalink / raw)
  To: Mikko.Soikkala, dirk.behme; +Cc: linux-omap-open-source

--- Mikko.Soikkala@Tietoenator.com wrote:

> 
> I'm still learning how to create and submit patches, but hopefully
> this
> does the trick.
> 
> Mikko
> 
>  	ts_omap.inputdevice = input_allocate_device();
> +	if (!ts_omap.inputdevice)
> +		return -ENOMEM;
> +

Not good enough. 

1. Need to free the irq, you just got before this code.
2. Need to call ts_omap.dev->remove() to match _probe() for the
corresponding platform before you return -ENOMEM.

---Komal Shah
http://komalshah.blogspot.com/

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

^ permalink raw reply	[flat|nested] 12+ messages in thread

* RE: [PATCH] Convert touchscreen to input_allocate_device
@ 2006-01-18  9:34 Mikko.Soikkala
  2006-01-18 10:10 ` Komal Shah
  0 siblings, 1 reply; 12+ messages in thread
From: Mikko.Soikkala @ 2006-01-18  9:34 UTC (permalink / raw)
  To: komal_shah802003, dirk.behme; +Cc: linux-omap-open-source

> -----Original Message-----
> From: Komal Shah [mailto:komal_shah802003@yahoo.com]
> 
> Not good enough.
> 
> 1. Need to free the irq, you just got before this code.
> 2. Need to call ts_omap.dev->remove() to match _probe() for the
> corresponding platform before you return -ENOMEM.> 

How about if we move the allocation and check to the beginning of the
probe function? Then the return shouldn't cause problems?

Mikko

--

diff -Naur linux-2.6.15-omap2/drivers/input/touchscreen/omap/omap_ts.c
linux-2.6.15-omap2-tsfix/drivers/input/touchscreen/omap/omap_ts.c
--- linux-2.6.15-omap2/drivers/input/touchscreen/omap/omap_ts.c
2006-01-17 14:39:49.000000000 +0200
+++ linux-2.6.15-omap2-tsfix/drivers/input/touchscreen/omap/omap_ts.c
2006-01-18 11:08:42.447581656 +0200
@@ -133,6 +133,10 @@
 	int status = -ENODEV;
 
 	memset(&ts_omap, 0, sizeof(ts_omap));
+	ts_omap.inputdevice = input_allocate_device();
+	if (!ts_omap.inputdevice)
+		return -ENOMEM;
+
 	spin_lock_init(&ts_omap.lock);
 
 	for (i = 0; i < ARRAY_SIZE(ts_devs); i++) {
@@ -167,7 +171,6 @@
 		return -EINVAL;
 	}
 
-	ts_omap.inputdevice = input_allocate_device();
 	ts_omap.inputdevice->name = OMAP_TS_NAME;
 	ts_omap.inputdevice->dev = &pdev->dev;
 	ts_omap.inputdevice->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); 

^ permalink raw reply	[flat|nested] 12+ messages in thread

* RE: [PATCH] Convert touchscreen to input_allocate_device
  2006-01-18  9:34 Mikko.Soikkala
@ 2006-01-18 10:10 ` Komal Shah
  2006-01-18 11:21   ` Juha Yrjölä
  0 siblings, 1 reply; 12+ messages in thread
From: Komal Shah @ 2006-01-18 10:10 UTC (permalink / raw)
  To: Mikko.Soikkala, dirk.behme; +Cc: linux-omap-open-source

--- Mikko.Soikkala@Tietoenator.com wrote:

> 
> How about if we move the allocation and check to the beginning of the
> probe function? Then the return shouldn't cause problems?

Ok. Looks good now.

---Komal Shah
http://komalshah.blogspot.com/

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] Convert touchscreen to input_allocate_device
  2006-01-18 10:10 ` Komal Shah
@ 2006-01-18 11:21   ` Juha Yrjölä
  2006-01-18 16:39     ` Komal Shah
  0 siblings, 1 reply; 12+ messages in thread
From: Juha Yrjölä @ 2006-01-18 11:21 UTC (permalink / raw)
  To: ext Komal Shah; +Cc: linux-omap-open-source, Mikko.Soikkala

On Wed, Jan 18, 2006 at 02:10:57AM -0800, ext Komal Shah wrote:

> > How about if we move the allocation and check to the beginning of the
> > probe function? Then the return shouldn't cause problems?
> 
> Ok. Looks good now.

Not quite yet. =) If you allocate the input device earlier, you also have to
take care in deallocating it in the error paths after it.

Cheers,
Juha

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] Convert touchscreen to input_allocate_device
  2006-01-18 11:21   ` Juha Yrjölä
@ 2006-01-18 16:39     ` Komal Shah
  2006-01-20 23:07       ` Tony Lindgren
  0 siblings, 1 reply; 12+ messages in thread
From: Komal Shah @ 2006-01-18 16:39 UTC (permalink / raw)
  Cc: linux-omap-open-source, Mikko.Soikkala

[-- Attachment #1: Type: text/plain, Size: 521 bytes --]

--- Juha Yrjölä <juha.yrjola@nokia.com> wrote:

> 
> Not quite yet. =) If you allocate the input device earlier, you also
> have to
> take care in deallocating it in the error paths after it.

Ok. Please check the attached patch. Build for OSK. 

Signed-off-by: Komal Shah <komal_shah802003@yahoo.com>


---Komal Shah
http://komalshah.blogspot.com/

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

[-- Attachment #2: 1479429603-tsfix.patch --]
[-- Type: text/plain, Size: 1531 bytes --]

diff --git a/drivers/input/touchscreen/corgi_ts.c b/drivers/input/touchscreen/corgi_ts.c
diff --git a/drivers/input/touchscreen/omap/omap_ts.c b/drivers/input/touchscreen/omap/omap_ts.c
index 5916245..f55ea05 100644
--- a/drivers/input/touchscreen/omap/omap_ts.c
+++ b/drivers/input/touchscreen/omap/omap_ts.c
@@ -133,6 +133,12 @@ static int __init omap_ts_probe(struct p
 	int status = -ENODEV;
 
 	memset(&ts_omap, 0, sizeof(ts_omap));
+	
+	ts_omap.inputdevice = input_allocate_device();
+	if (!ts_omap.inputdevice) {
+		return -ENOMEM;
+	}
+
 	spin_lock_init(&ts_omap.lock);
 
 	for (i = 0; i < ARRAY_SIZE(ts_devs); i++) {
@@ -145,8 +151,10 @@ static int __init omap_ts_probe(struct p
 		}
 	}
 
-	if (status != 0)
+	if (status != 0) {
+	    	input_free_device(ts_omap.inputdevice);
 		return status;
+	}
 
 	// Init acquisition timer function
 	init_timer(&ts_omap.ts_timer);
@@ -159,15 +167,18 @@ static int __init omap_ts_probe(struct p
 			printk(KERN_ERR
 	  "omap_ts.c: Could not allocate touchscreen IRQ!\n");
 			ts_omap.irq = -1;
+			ts_omap.dev->remove();
+			input_free_device(ts_omap.inputdevice);
 			return -EINVAL;
 		}
 		ts_omap.irq_enabled = 1;
 	} else {
 		printk(KERN_ERR "omap_ts.c: No touchscreen IRQ assigned!\n");
+		ts_omap.dev->remove();
+		input_free_device(ts_omap.inputdevice);
 		return -EINVAL;
 	}
 
-	ts_omap.inputdevice = input_allocate_device();
 	ts_omap.inputdevice->name = OMAP_TS_NAME;
 	ts_omap.inputdevice->dev = &pdev->dev;
 	ts_omap.inputdevice->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);

[-- Attachment #3: Type: text/plain, Size: 0 bytes --]



^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH] Convert touchscreen to input_allocate_device
  2006-01-18 16:39     ` Komal Shah
@ 2006-01-20 23:07       ` Tony Lindgren
  0 siblings, 0 replies; 12+ messages in thread
From: Tony Lindgren @ 2006-01-20 23:07 UTC (permalink / raw)
  To: Komal Shah; +Cc: Mikko.Soikkala, linux-omap-open-source

* Komal Shah <komal_shah802003@yahoo.com> [060118 08:47]:
> --- Juha Yrjölä <juha.yrjola@nokia.com> wrote:
> 
> > 
> > Not quite yet. =) If you allocate the input device earlier, you also
> > have to
> > take care in deallocating it in the error paths after it.
> 
> Ok. Please check the attached patch. Build for OSK. 
> 
> Signed-off-by: Komal Shah <komal_shah802003@yahoo.com>
> 
> 
> ---Komal Shah
> http://komalshah.blogspot.com/
> 
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around 
> http://mail.yahoo.com 
Content-Description: 1479429603-tsfix.patch
> diff --git a/drivers/input/touchscreen/corgi_ts.c b/drivers/input/touchscreen/corgi_ts.c
> diff --git a/drivers/input/touchscreen/omap/omap_ts.c b/drivers/input/touchscreen/omap/omap_ts.c
> index 5916245..f55ea05 100644
> --- a/drivers/input/touchscreen/omap/omap_ts.c
> +++ b/drivers/input/touchscreen/omap/omap_ts.c
> @@ -133,6 +133,12 @@ static int __init omap_ts_probe(struct p
>  	int status = -ENODEV;
>  
>  	memset(&ts_omap, 0, sizeof(ts_omap));
> +	
> +	ts_omap.inputdevice = input_allocate_device();
> +	if (!ts_omap.inputdevice) {
> +		return -ENOMEM;
> +	}
> +
>  	spin_lock_init(&ts_omap.lock);
>  
>  	for (i = 0; i < ARRAY_SIZE(ts_devs); i++) {
> @@ -145,8 +151,10 @@ static int __init omap_ts_probe(struct p
>  		}
>  	}
>  
> -	if (status != 0)
> +	if (status != 0) {
> +	    	input_free_device(ts_omap.inputdevice);
>  		return status;
> +	}
>  
>  	// Init acquisition timer function
>  	init_timer(&ts_omap.ts_timer);
> @@ -159,15 +167,18 @@ static int __init omap_ts_probe(struct p
>  			printk(KERN_ERR
>  	  "omap_ts.c: Could not allocate touchscreen IRQ!\n");
>  			ts_omap.irq = -1;
> +			ts_omap.dev->remove();
> +			input_free_device(ts_omap.inputdevice);
>  			return -EINVAL;
>  		}
>  		ts_omap.irq_enabled = 1;
>  	} else {
>  		printk(KERN_ERR "omap_ts.c: No touchscreen IRQ assigned!\n");
> +		ts_omap.dev->remove();
> +		input_free_device(ts_omap.inputdevice);
>  		return -EINVAL;
>  	}
>  
> -	ts_omap.inputdevice = input_allocate_device();
>  	ts_omap.inputdevice->name = OMAP_TS_NAME;
>  	ts_omap.inputdevice->dev = &pdev->dev;
>  	ts_omap.inputdevice->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);

Pushing today.

Tony

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2006-01-20 23:07 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-01-16 11:59 [PATCH] Convert touchscreen to input_allocate_device Mikko.Soikkala
2006-01-16 18:15 ` Dirk Behme
  -- strict thread matches above, loose matches on Subject: below --
2006-01-18  9:34 Mikko.Soikkala
2006-01-18 10:10 ` Komal Shah
2006-01-18 11:21   ` Juha Yrjölä
2006-01-18 16:39     ` Komal Shah
2006-01-20 23:07       ` Tony Lindgren
2006-01-17 13:24 Mikko.Soikkala
2006-01-17 15:12 ` Komal Shah
2005-12-27  9:51 Pending patches Dirk Behme
2005-12-30 22:28 ` Tony Lindgren
2006-01-03 19:13   ` Pending patches mostly pushed, please check Tony Lindgren
2006-01-06 19:37     ` [PATCH] Convert touchscreen to input_allocate_device Dirk Behme
2006-01-14  0:18       ` Tony Lindgren
2005-12-04 15:52 Dirk Behme

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox