diff options
author | Jiri Slaby <jslaby@suse.cz> | 2012-06-04 07:35:33 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-06-13 20:30:53 -0400 |
commit | bc1e99d93f096d5736c0bd3c2d17e13f27b6eb09 (patch) | |
tree | 174133b5869279f698f331bd6782ff8d5bff51ef /drivers/tty/vt | |
parent | 695586ca20c56cf8cfa87160383307a288d32496 (diff) |
TTY: vt, add ->install
We need to initialize the console only on the first open. This is
usually what is done in the ->install hook. vt used to do this in
->open. Now we move it to ->install and use newly added helper for
install: tty_port_install. It ensures tty->port to be set properly.
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/tty/vt')
-rw-r--r-- | drivers/tty/vt/vt.c | 60 |
1 files changed, 36 insertions, 24 deletions
diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c index 88a4914ef557..7cb53c236339 100644 --- a/drivers/tty/vt/vt.c +++ b/drivers/tty/vt/vt.c | |||
@@ -2792,41 +2792,52 @@ static void con_flush_chars(struct tty_struct *tty) | |||
2792 | /* | 2792 | /* |
2793 | * Allocate the console screen memory. | 2793 | * Allocate the console screen memory. |
2794 | */ | 2794 | */ |
2795 | static int con_open(struct tty_struct *tty, struct file *filp) | 2795 | static int con_install(struct tty_driver *driver, struct tty_struct *tty) |
2796 | { | 2796 | { |
2797 | unsigned int currcons = tty->index; | 2797 | unsigned int currcons = tty->index; |
2798 | int ret = 0; | 2798 | struct vc_data *vc; |
2799 | int ret; | ||
2799 | 2800 | ||
2800 | console_lock(); | 2801 | console_lock(); |
2801 | if (tty->driver_data == NULL) { | 2802 | ret = vc_allocate(currcons); |
2802 | ret = vc_allocate(currcons); | 2803 | if (ret) |
2803 | if (ret == 0) { | 2804 | goto unlock; |
2804 | struct vc_data *vc = vc_cons[currcons].d; | ||
2805 | 2805 | ||
2806 | /* Still being freed */ | 2806 | vc = vc_cons[currcons].d; |
2807 | if (vc->port.tty) { | ||
2808 | console_unlock(); | ||
2809 | return -ERESTARTSYS; | ||
2810 | } | ||
2811 | tty->driver_data = vc; | ||
2812 | vc->port.tty = tty; | ||
2813 | 2807 | ||
2814 | if (!tty->winsize.ws_row && !tty->winsize.ws_col) { | 2808 | /* Still being freed */ |
2815 | tty->winsize.ws_row = vc_cons[currcons].d->vc_rows; | 2809 | if (vc->port.tty) { |
2816 | tty->winsize.ws_col = vc_cons[currcons].d->vc_cols; | 2810 | ret = -ERESTARTSYS; |
2817 | } | 2811 | goto unlock; |
2818 | if (vc->vc_utf) | ||
2819 | tty->termios->c_iflag |= IUTF8; | ||
2820 | else | ||
2821 | tty->termios->c_iflag &= ~IUTF8; | ||
2822 | console_unlock(); | ||
2823 | return ret; | ||
2824 | } | ||
2825 | } | 2812 | } |
2813 | |||
2814 | ret = tty_port_install(&vc->port, driver, tty); | ||
2815 | if (ret) | ||
2816 | goto unlock; | ||
2817 | |||
2818 | tty->driver_data = vc; | ||
2819 | vc->port.tty = tty; | ||
2820 | |||
2821 | if (!tty->winsize.ws_row && !tty->winsize.ws_col) { | ||
2822 | tty->winsize.ws_row = vc_cons[currcons].d->vc_rows; | ||
2823 | tty->winsize.ws_col = vc_cons[currcons].d->vc_cols; | ||
2824 | } | ||
2825 | if (vc->vc_utf) | ||
2826 | tty->termios->c_iflag |= IUTF8; | ||
2827 | else | ||
2828 | tty->termios->c_iflag &= ~IUTF8; | ||
2829 | unlock: | ||
2826 | console_unlock(); | 2830 | console_unlock(); |
2827 | return ret; | 2831 | return ret; |
2828 | } | 2832 | } |
2829 | 2833 | ||
2834 | static int con_open(struct tty_struct *tty, struct file *filp) | ||
2835 | { | ||
2836 | /* everything done in install */ | ||
2837 | return 0; | ||
2838 | } | ||
2839 | |||
2840 | |||
2830 | static void con_close(struct tty_struct *tty, struct file *filp) | 2841 | static void con_close(struct tty_struct *tty, struct file *filp) |
2831 | { | 2842 | { |
2832 | /* Nothing to do - we defer to shutdown */ | 2843 | /* Nothing to do - we defer to shutdown */ |
@@ -2947,6 +2958,7 @@ static int __init con_init(void) | |||
2947 | console_initcall(con_init); | 2958 | console_initcall(con_init); |
2948 | 2959 | ||
2949 | static const struct tty_operations con_ops = { | 2960 | static const struct tty_operations con_ops = { |
2961 | .install = con_install, | ||
2950 | .open = con_open, | 2962 | .open = con_open, |
2951 | .close = con_close, | 2963 | .close = con_close, |
2952 | .write = con_write, | 2964 | .write = con_write, |