diff options
author | Arjan van de Ven <arjan@infradead.org> | 2006-09-29 05:00:43 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-09-29 12:18:16 -0400 |
commit | 5785c95baede8459d70c4aa0f7becb6e8b5fde4b (patch) | |
tree | 17744eac694b4eab81cba4db28c4e083d779b753 /drivers/char/tty_io.c | |
parent | 54306cf04c0ea0a8c432603dbc657ab62a438668 (diff) |
[PATCH] tty: make termios_sem a mutex
[akpm@osdl.org: fix]
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
Cc: Arjan van de Ven <arjan@infradead.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/char/tty_io.c')
-rw-r--r-- | drivers/char/tty_io.c | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c index b4f37c65b95c..142427c6e8f3 100644 --- a/drivers/char/tty_io.c +++ b/drivers/char/tty_io.c | |||
@@ -618,9 +618,9 @@ EXPORT_SYMBOL_GPL(tty_prepare_flip_string_flags); | |||
618 | 618 | ||
619 | static void tty_set_termios_ldisc(struct tty_struct *tty, int num) | 619 | static void tty_set_termios_ldisc(struct tty_struct *tty, int num) |
620 | { | 620 | { |
621 | down(&tty->termios_sem); | 621 | mutex_lock(&tty->termios_mutex); |
622 | tty->termios->c_line = num; | 622 | tty->termios->c_line = num; |
623 | up(&tty->termios_sem); | 623 | mutex_unlock(&tty->termios_mutex); |
624 | } | 624 | } |
625 | 625 | ||
626 | /* | 626 | /* |
@@ -1338,9 +1338,9 @@ static void do_tty_hangup(void *data) | |||
1338 | */ | 1338 | */ |
1339 | if (tty->driver->flags & TTY_DRIVER_RESET_TERMIOS) | 1339 | if (tty->driver->flags & TTY_DRIVER_RESET_TERMIOS) |
1340 | { | 1340 | { |
1341 | down(&tty->termios_sem); | 1341 | mutex_lock(&tty->termios_mutex); |
1342 | *tty->termios = tty->driver->init_termios; | 1342 | *tty->termios = tty->driver->init_termios; |
1343 | up(&tty->termios_sem); | 1343 | mutex_unlock(&tty->termios_mutex); |
1344 | } | 1344 | } |
1345 | 1345 | ||
1346 | /* Defer ldisc switch */ | 1346 | /* Defer ldisc switch */ |
@@ -2750,9 +2750,9 @@ static int tiocgwinsz(struct tty_struct *tty, struct winsize __user * arg) | |||
2750 | { | 2750 | { |
2751 | int err; | 2751 | int err; |
2752 | 2752 | ||
2753 | down(&tty->termios_sem); | 2753 | mutex_lock(&tty->termios_mutex); |
2754 | err = copy_to_user(arg, &tty->winsize, sizeof(*arg)); | 2754 | err = copy_to_user(arg, &tty->winsize, sizeof(*arg)); |
2755 | up(&tty->termios_sem); | 2755 | mutex_unlock(&tty->termios_mutex); |
2756 | 2756 | ||
2757 | return err ? -EFAULT: 0; | 2757 | return err ? -EFAULT: 0; |
2758 | } | 2758 | } |
@@ -2782,14 +2782,15 @@ static int tiocswinsz(struct tty_struct *tty, struct tty_struct *real_tty, | |||
2782 | if (copy_from_user(&tmp_ws, arg, sizeof(*arg))) | 2782 | if (copy_from_user(&tmp_ws, arg, sizeof(*arg))) |
2783 | return -EFAULT; | 2783 | return -EFAULT; |
2784 | 2784 | ||
2785 | down(&tty->termios_sem); | 2785 | mutex_lock(&tty->termios_mutex); |
2786 | if (!memcmp(&tmp_ws, &tty->winsize, sizeof(*arg))) | 2786 | if (!memcmp(&tmp_ws, &tty->winsize, sizeof(*arg))) |
2787 | goto done; | 2787 | goto done; |
2788 | 2788 | ||
2789 | #ifdef CONFIG_VT | 2789 | #ifdef CONFIG_VT |
2790 | if (tty->driver->type == TTY_DRIVER_TYPE_CONSOLE) { | 2790 | if (tty->driver->type == TTY_DRIVER_TYPE_CONSOLE) { |
2791 | if (vc_lock_resize(tty->driver_data, tmp_ws.ws_col, tmp_ws.ws_row)) { | 2791 | if (vc_lock_resize(tty->driver_data, tmp_ws.ws_col, |
2792 | up(&tty->termios_sem); | 2792 | tmp_ws.ws_row)) { |
2793 | mutex_unlock(&tty->termios_mutex); | ||
2793 | return -ENXIO; | 2794 | return -ENXIO; |
2794 | } | 2795 | } |
2795 | } | 2796 | } |
@@ -2801,7 +2802,7 @@ static int tiocswinsz(struct tty_struct *tty, struct tty_struct *real_tty, | |||
2801 | tty->winsize = tmp_ws; | 2802 | tty->winsize = tmp_ws; |
2802 | real_tty->winsize = tmp_ws; | 2803 | real_tty->winsize = tmp_ws; |
2803 | done: | 2804 | done: |
2804 | up(&tty->termios_sem); | 2805 | mutex_unlock(&tty->termios_mutex); |
2805 | return 0; | 2806 | return 0; |
2806 | } | 2807 | } |
2807 | 2808 | ||
@@ -3576,7 +3577,7 @@ static void initialize_tty_struct(struct tty_struct *tty) | |||
3576 | tty_buffer_init(tty); | 3577 | tty_buffer_init(tty); |
3577 | INIT_WORK(&tty->buf.work, flush_to_ldisc, tty); | 3578 | INIT_WORK(&tty->buf.work, flush_to_ldisc, tty); |
3578 | init_MUTEX(&tty->buf.pty_sem); | 3579 | init_MUTEX(&tty->buf.pty_sem); |
3579 | init_MUTEX(&tty->termios_sem); | 3580 | mutex_init(&tty->termios_mutex); |
3580 | init_waitqueue_head(&tty->write_wait); | 3581 | init_waitqueue_head(&tty->write_wait); |
3581 | init_waitqueue_head(&tty->read_wait); | 3582 | init_waitqueue_head(&tty->read_wait); |
3582 | INIT_WORK(&tty->hangup_work, do_tty_hangup, tty); | 3583 | INIT_WORK(&tty->hangup_work, do_tty_hangup, tty); |