From: Russell King Add console_stop() and console_start() methods so the serial drivers can disable console output before suspending a port, and re-enable output afterwards. We also add locking to ensure that we synchronise with any in-progress printk. Signed-off-by: Andrew Morton --- 25-akpm/drivers/serial/serial_core.c | 4 ++-- 25-akpm/include/linux/console.h | 2 ++ 25-akpm/kernel/printk.c | 21 +++++++++++++++++++++ 3 files changed, 25 insertions(+), 2 deletions(-) diff -puN drivers/serial/serial_core.c~provide-console_suspend-and-console_resume drivers/serial/serial_core.c --- 25/drivers/serial/serial_core.c~provide-console_suspend-and-console_resume 2004-06-28 00:58:58.516883064 -0700 +++ 25-akpm/drivers/serial/serial_core.c 2004-06-28 00:58:58.524881848 -0700 @@ -1923,7 +1923,7 @@ int uart_suspend_port(struct uart_driver * Disable the console device before suspending. */ if (uart_console(port)) - port->cons->flags &= ~CON_ENABLED; + console_stop(port->cons); uart_change_pm(state, 3); @@ -1945,7 +1945,7 @@ int uart_resume_port(struct uart_driver */ if (uart_console(port)) { uart_change_speed(state, NULL); - port->cons->flags |= CON_ENABLED; + console_start(port->cons); } if (state->info && state->info->flags & UIF_INITIALIZED) { diff -puN include/linux/console.h~provide-console_suspend-and-console_resume include/linux/console.h --- 25/include/linux/console.h~provide-console_suspend-and-console_resume 2004-06-28 00:58:58.518882760 -0700 +++ 25-akpm/include/linux/console.h 2004-06-28 00:58:58.525881696 -0700 @@ -105,6 +105,8 @@ extern void release_console_sem(void); extern void console_conditional_schedule(void); extern void console_unblank(void); extern struct tty_driver *console_device(int *); +extern void console_stop(struct console *); +extern void console_start(struct console *); extern int is_console_locked(void); /* Some debug stub to catch some of the obvious races in the VT code */ diff -puN kernel/printk.c~provide-console_suspend-and-console_resume kernel/printk.c --- 25/kernel/printk.c~provide-console_suspend-and-console_resume 2004-06-28 00:58:58.519882608 -0700 +++ 25-akpm/kernel/printk.c 2004-06-28 00:58:58.526881544 -0700 @@ -704,6 +704,27 @@ struct tty_driver *console_device(int *i } /* + * Prevent further output on the passed console device so that (for example) + * serial drivers can disable console output before suspending a port, and can + * re-enable output afterwards. + */ +void console_stop(struct console *console) +{ + acquire_console_sem(); + console->flags &= ~CON_ENABLED; + release_console_sem(); +} +EXPORT_SYMBOL(console_stop); + +void console_start(struct console *console) +{ + acquire_console_sem(); + console->flags |= CON_ENABLED; + release_console_sem(); +} +EXPORT_SYMBOL(console_start); + +/* * The console driver calls this routine during kernel initialization * to register the console printing procedure with printk() and to * print any messages that were printed by the kernel before the _