diff options
author | Miod Vallat <miod@cvs.openbsd.org> | 2003-10-03 16:44:52 +0000 |
---|---|---|
committer | Miod Vallat <miod@cvs.openbsd.org> | 2003-10-03 16:44:52 +0000 |
commit | 24c386b577f126bce761c7288e987ae93c36aa88 (patch) | |
tree | 99166e0d499a2be11543cc5dd9774c63a12466eb /sys/kern/tty.c | |
parent | e43c66ff4e929d0beb6716fb882523dc136b8c0c (diff) |
Merge tty_attach() in ttymalloc() and tty_detach() in ttyfree(). The need for
separate tty registering is gone now that sparc has switched to wscons, and
this makes the code less error-prone.
Also, remove tests for ttymalloc() failure, since it uses M_WAITOK.
ok millert@ deraadt@, tested by various people as well besides me...
Diffstat (limited to 'sys/kern/tty.c')
-rw-r--r-- | sys/kern/tty.c | 61 |
1 files changed, 17 insertions, 44 deletions
diff --git a/sys/kern/tty.c b/sys/kern/tty.c index 1a86d45a0d6..10e99856386 100644 --- a/sys/kern/tty.c +++ b/sys/kern/tty.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tty.c,v 1.61 2003/09/23 16:51:12 millert Exp $ */ +/* $OpenBSD: tty.c,v 1.62 2003/10/03 16:44:51 miod Exp $ */ /* $NetBSD: tty.c,v 1.68.4.2 1996/06/06 16:04:52 thorpej Exp $ */ /*- @@ -2260,45 +2260,8 @@ tty_init() } /* - * Attach a tty to the tty list. - * - * This should be called ONLY once per real tty (including pty's). - * eg, on the sparc, the keyboard and mouse have struct tty's that are - * distinctly NOT usable as tty's, and thus should not be attached to - * the ttylist. This is why this call is not done from ttymalloc(). - * - * Device drivers should attach tty's at a similar time that they are - * ttymalloc()'ed, or, for the case of statically allocated struct tty's - * either in the attach or (first) open routine. - */ -void -tty_attach(tp) - struct tty *tp; -{ - - TAILQ_INSERT_TAIL(&ttylist, tp, tty_link); - ++tty_count; - timeout_set(&tp->t_rstrt_to, ttrstrt, tp); -} - -/* - * Remove a tty from the tty list. - */ -void -tty_detach(tp) - struct tty *tp; -{ - - --tty_count; -#ifdef DIAGNOSTIC - if (tty_count < 0) - panic("tty_detach: tty_count < 0"); -#endif - TAILQ_REMOVE(&ttylist, tp, tty_link); -} - -/* - * Allocate a tty structure and its associated buffers. + * Allocate a tty structure and its associated buffers, and attach it to the + * tty list. */ struct tty * ttymalloc() @@ -2312,20 +2275,30 @@ ttymalloc() clalloc(&tp->t_canq, 1024, 1); /* output queue doesn't need quoting */ clalloc(&tp->t_outq, 1024, 0); + + TAILQ_INSERT_TAIL(&ttylist, tp, tty_link); + ++tty_count; + timeout_set(&tp->t_rstrt_to, ttrstrt, tp); + return(tp); } + /* - * Free a tty structure and its buffers. - * - * Be sure to call tty_detach() for any tty that has been - * tty_attach()ed. + * Free a tty structure and its buffers, after removing it from the tty list. */ void ttyfree(tp) struct tty *tp; { + --tty_count; +#ifdef DIAGNOSTIC + if (tty_count < 0) + panic("ttyfree: tty_count < 0"); +#endif + TAILQ_REMOVE(&ttylist, tp, tty_link); + clfree(&tp->t_rawq); clfree(&tp->t_canq); clfree(&tp->t_outq); |