diff options
author | Peter Hurley <peter@hurleysoftware.com> | 2015-09-25 15:36:11 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2015-10-04 14:12:25 -0400 |
commit | 10791233e98fbd0ed84b9ba549ce537ca2fcccf3 (patch) | |
tree | 8f6ab424c893b9a0e8c85da75a8bcb442e4dc0b5 | |
parent | 4f56f3fdca43c9a18339b6e0c3b1aa2f57f6d0b0 (diff) |
serial: 8250: Refactor serial console restore-from-suspend
Move h/w reinit of serial console restore-from-suspend into
standalone helper function.
No functional change.
Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/tty/serial/8250/8250_port.c | 36 |
1 files changed, 22 insertions, 14 deletions
diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/8250_port.c index e54de0037df4..e27c761ec984 100644 --- a/drivers/tty/serial/8250/8250_port.c +++ b/drivers/tty/serial/8250/8250_port.c | |||
@@ -2803,6 +2803,27 @@ static void serial8250_console_putchar(struct uart_port *port, int ch) | |||
2803 | } | 2803 | } |
2804 | 2804 | ||
2805 | /* | 2805 | /* |
2806 | * Restore serial console when h/w power-off detected | ||
2807 | */ | ||
2808 | static void serial8250_console_restore(struct uart_8250_port *up) | ||
2809 | { | ||
2810 | struct uart_port *port = &up->port; | ||
2811 | struct ktermios termios; | ||
2812 | unsigned int baud, quot, frac = 0; | ||
2813 | |||
2814 | termios.c_cflag = port->cons->cflag; | ||
2815 | if (port->state->port.tty && termios.c_cflag == 0) | ||
2816 | termios.c_cflag = port->state->port.tty->termios.c_cflag; | ||
2817 | |||
2818 | baud = serial8250_get_baud_rate(port, &termios, NULL); | ||
2819 | quot = serial8250_get_divisor(up, baud, &frac); | ||
2820 | |||
2821 | serial8250_set_divisor(port, baud, quot, frac); | ||
2822 | serial_port_out(port, UART_LCR, up->lcr); | ||
2823 | serial_port_out(port, UART_MCR, UART_MCR_DTR | UART_MCR_RTS); | ||
2824 | } | ||
2825 | |||
2826 | /* | ||
2806 | * Print a string to the serial port trying not to disturb | 2827 | * Print a string to the serial port trying not to disturb |
2807 | * any possible real use of the port... | 2828 | * any possible real use of the port... |
2808 | * | 2829 | * |
@@ -2839,20 +2860,7 @@ void serial8250_console_write(struct uart_8250_port *up, const char *s, | |||
2839 | 2860 | ||
2840 | /* check scratch reg to see if port powered off during system sleep */ | 2861 | /* check scratch reg to see if port powered off during system sleep */ |
2841 | if (up->canary && (up->canary != serial_port_in(port, UART_SCR))) { | 2862 | if (up->canary && (up->canary != serial_port_in(port, UART_SCR))) { |
2842 | struct ktermios termios; | 2863 | serial8250_console_restore(up); |
2843 | unsigned int baud, quot, frac = 0; | ||
2844 | |||
2845 | termios.c_cflag = port->cons->cflag; | ||
2846 | if (port->state->port.tty && termios.c_cflag == 0) | ||
2847 | termios.c_cflag = port->state->port.tty->termios.c_cflag; | ||
2848 | |||
2849 | baud = serial8250_get_baud_rate(port, &termios, NULL); | ||
2850 | quot = serial8250_get_divisor(up, baud, &frac); | ||
2851 | |||
2852 | serial8250_set_divisor(port, baud, quot, frac); | ||
2853 | serial_port_out(port, UART_LCR, up->lcr); | ||
2854 | serial_port_out(port, UART_MCR, UART_MCR_DTR | UART_MCR_RTS); | ||
2855 | |||
2856 | up->canary = 0; | 2864 | up->canary = 0; |
2857 | } | 2865 | } |
2858 | 2866 | ||