linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [2.6 PATCH] Input: unregister i8042 port when writing to control register fails
@ 2003-11-30  8:08 Dmitry Torokhov
  0 siblings, 0 replies; only message in thread
From: Dmitry Torokhov @ 2003-11-30  8:08 UTC (permalink / raw)
  To: linux-kernel; +Cc: Vojtech Pavlik, Andrew Morton

I think that if we can't write to the control register it's not less critical
than not having a free IRQ so we better unregister port in this case as well.

Also logging moved a bit.

Dmitry

===================================================================

ChangeSet@1.1513, 2003-11-30 02:50:21-05:00, dtor_core@ameritech.net
  Input: Unregister port not only when there us no free IRQ
         available but also when write to control register 
         failed.
         Also moved logging a bit.


 i8042.c |   22 +++++++++++++++-------
 1 files changed, 15 insertions(+), 7 deletions(-)

===================================================================

diff -Nru a/drivers/input/serio/i8042.c b/drivers/input/serio/i8042.c
--- a/drivers/input/serio/i8042.c	Sun Nov 30 03:06:50 2003
+++ b/drivers/input/serio/i8042.c	Sun Nov 30 03:06:50 2003
@@ -231,21 +231,29 @@
 	if (request_irq(values->irq, i8042_interrupt,
 			SA_SHIRQ, "i8042", i8042_request_irq_cookie)) {
 		printk(KERN_ERR "i8042.c: Can't get irq %d for %s, unregistering the port.\n", values->irq, values->name);
-		values->exists = 0;
-		serio_unregister_port(port);
-		return -1;
+		goto irq_fail;
 	}
 
 	i8042_ctr |= values->irqen;
 
 	if (i8042_command(&i8042_ctr, I8042_CMD_CTL_WCTR)) {
-		printk(KERN_ERR "i8042.c: Can't write CTR while opening %s.\n", values->name);
-		return -1;
+		printk(KERN_ERR "i8042.c: Can't write CTR while opening %s, unregistering the port\n", values->name);
+		goto ctr_fail;
 	}
 
 	i8042_interrupt(0, NULL, NULL);
 
 	return 0;
+
+ctr_fail:
+	i8042_ctr &= ~values->irqen;
+	free_irq(values->irq, i8042_request_irq_cookie);
+
+irq_fail:
+	values->exists = 0;
+	serio_unregister_port(port);
+
+	return -1;
 }
 
 /*
@@ -691,13 +699,13 @@
 		return -1; 
 	}
 
-	serio_register_port(port);
-
 	printk(KERN_INFO "serio: i8042 %s port at %#lx,%#lx irq %d\n",
 	       values->name,
 	       (unsigned long) I8042_DATA_REG,
 	       (unsigned long) I8042_COMMAND_REG,
 	       values->irq);
+
+	serio_register_port(port);
 
 	return 0;
 }


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2003-11-30  8:08 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-11-30  8:08 [2.6 PATCH] Input: unregister i8042 port when writing to control register fails Dmitry Torokhov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).