aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/serial
diff options
context:
space:
mode:
authorJason Wessel <jason.wessel@windriver.com>2009-06-22 12:32:20 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2009-07-12 18:16:39 -0400
commit6e4061210150d1d6d388c5fba05f6b49a306a27e (patch)
tree7c059e60623fab637b2049bdf59b42040025b00b /drivers/usb/serial
parentbf7fbb022f0a3da27a2bcf8d7c973c813d942384 (diff)
USB: console: Fix regression in usb console on kernel boot
The commit 335f8514f200e63d689113d29cb7253a5c282967 introduced a regression which stopped usb consoles from working correctly as a kernel boot console as well as interactive login device. The addition of the serial_close() which in turn calls tty_port_close_start() will change the reference count of port.count and warn about it. The usb console code had previously incremented the port.count to indicate it was making use of the device as a console and the forced change causes a double open on the usb device which leads to a non obvious kernel oops later on when the tty is freed. To fix the problem instead make use of port->console to track if the port is in fact an active console port to avoid double initialization of the usb serial device. The port.count is incremented and decremented only with in the scope of usb_console_setup() for the purpose of the low level driver initialization. Signed-off-by: Jason Wessel <jason.wessel@windriver.com> Acked-by: Alan Cox <alan@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/serial')
-rw-r--r--drivers/usb/serial/console.c13
-rw-r--r--drivers/usb/serial/usb-serial.c3
2 files changed, 9 insertions, 7 deletions
diff --git a/drivers/usb/serial/console.c b/drivers/usb/serial/console.c
index 247b61bfb7f4..0e4f2e41ace5 100644
--- a/drivers/usb/serial/console.c
+++ b/drivers/usb/serial/console.c
@@ -169,9 +169,11 @@ static int usb_console_setup(struct console *co, char *options)
169 kfree(tty); 169 kfree(tty);
170 } 170 }
171 } 171 }
172 /* So we know not to kill the hardware on a hangup on this 172 /* Now that any required fake tty operations are completed restore
173 port. We have also bumped the use count by one so it won't go 173 * the tty port count */
174 idle */ 174 --port->port.count;
175 /* The console is special in terms of closing the device so
176 * indicate this port is now acting as a system console. */
175 port->console = 1; 177 port->console = 1;
176 retval = 0; 178 retval = 0;
177 179
@@ -204,7 +206,7 @@ static void usb_console_write(struct console *co,
204 206
205 dbg("%s - port %d, %d byte(s)", __func__, port->number, count); 207 dbg("%s - port %d, %d byte(s)", __func__, port->number, count);
206 208
207 if (!port->port.count) { 209 if (!port->console) {
208 dbg("%s - port not opened", __func__); 210 dbg("%s - port not opened", __func__);
209 return; 211 return;
210 } 212 }
@@ -300,8 +302,7 @@ void usb_serial_console_exit(void)
300{ 302{
301 if (usbcons_info.port) { 303 if (usbcons_info.port) {
302 unregister_console(&usbcons); 304 unregister_console(&usbcons);
303 if (usbcons_info.port->port.count) 305 usbcons_info.port->console = 0;
304 usbcons_info.port->port.count--;
305 usbcons_info.port = NULL; 306 usbcons_info.port = NULL;
306 } 307 }
307} 308}
diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c
index a84216464ca0..9e6027b3a2e9 100644
--- a/drivers/usb/serial/usb-serial.c
+++ b/drivers/usb/serial/usb-serial.c
@@ -220,7 +220,8 @@ static int serial_open (struct tty_struct *tty, struct file *filp)
220 tty->driver_data = port; 220 tty->driver_data = port;
221 tty_port_tty_set(&port->port, tty); 221 tty_port_tty_set(&port->port, tty);
222 222
223 if (port->port.count == 1) { 223 /* If the console is attached, the device is already open */
224 if (port->port.count == 1 && !port->console) {
224 225
225 /* lock this module before we call it 226 /* lock this module before we call it
226 * this may fail, which means we must bail out, 227 * this may fail, which means we must bail out,