aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorPavel Machek <pavel@ucw.cz>2006-03-08 00:55:20 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2006-03-08 17:14:00 -0500
commitd5f735e52fb41e032b0db08aa20c02dbb9cd0db3 (patch)
tree901eb8df0c58c1776dda88e91b997e6c0d39b48c /drivers
parent1c6cc5fd32978ffdc4d0acf8592d3901adefbdad (diff)
[PATCH] serial core: work around sub-driver bugs
We're presently getting oopses because Bluetooth (and possibly other) drivers are calling core functions after things have been shut down. So rather than oopsing, let's drop a warning then take avoiding action, so the machine survives. Once all the sub-drivers are fixed up we can remove the take-avoiding-action part. Signed-off-by: Pavel Machek <pavel@suse.cz> Cc: Russell King <rmk@arm.linux.org.uk> Cc: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/serial/serial_core.c32
1 files changed, 29 insertions, 3 deletions
diff --git a/drivers/serial/serial_core.c b/drivers/serial/serial_core.c
index 95fb4939c675..cc1faa31d124 100644
--- a/drivers/serial/serial_core.c
+++ b/drivers/serial/serial_core.c
@@ -71,6 +71,11 @@ static void uart_change_pm(struct uart_state *state, int pm_state);
71void uart_write_wakeup(struct uart_port *port) 71void uart_write_wakeup(struct uart_port *port)
72{ 72{
73 struct uart_info *info = port->info; 73 struct uart_info *info = port->info;
74 /*
75 * This means you called this function _after_ the port was
76 * closed. No cookie for you.
77 */
78 BUG_ON(!info);
74 tasklet_schedule(&info->tlet); 79 tasklet_schedule(&info->tlet);
75} 80}
76 81
@@ -471,14 +476,26 @@ static void uart_flush_chars(struct tty_struct *tty)
471} 476}
472 477
473static int 478static int
474uart_write(struct tty_struct *tty, const unsigned char * buf, int count) 479uart_write(struct tty_struct *tty, const unsigned char *buf, int count)
475{ 480{
476 struct uart_state *state = tty->driver_data; 481 struct uart_state *state = tty->driver_data;
477 struct uart_port *port = state->port; 482 struct uart_port *port;
478 struct circ_buf *circ = &state->info->xmit; 483 struct circ_buf *circ;
479 unsigned long flags; 484 unsigned long flags;
480 int c, ret = 0; 485 int c, ret = 0;
481 486
487 /*
488 * This means you called this function _after_ the port was
489 * closed. No cookie for you.
490 */
491 if (!state || !state->info) {
492 WARN_ON(1);
493 return -EL3HLT;
494 }
495
496 port = state->port;
497 circ = &state->info->xmit;
498
482 if (!circ->buf) 499 if (!circ->buf)
483 return 0; 500 return 0;
484 501
@@ -521,6 +538,15 @@ static void uart_flush_buffer(struct tty_struct *tty)
521 struct uart_port *port = state->port; 538 struct uart_port *port = state->port;
522 unsigned long flags; 539 unsigned long flags;
523 540
541 /*
542 * This means you called this function _after_ the port was
543 * closed. No cookie for you.
544 */
545 if (!state || !state->info) {
546 WARN_ON(1);
547 return;
548 }
549
524 DPRINTK("uart_flush_buffer(%d) called\n", tty->index); 550 DPRINTK("uart_flush_buffer(%d) called\n", tty->index);
525 551
526 spin_lock_irqsave(&port->lock, flags); 552 spin_lock_irqsave(&port->lock, flags);