diff options
36 files changed, 63 insertions, 150 deletions
diff --git a/sys/arch/alpha/alpha/promcons.c b/sys/arch/alpha/alpha/promcons.c index c787f39e92c..836aceb0567 100644 --- a/sys/arch/alpha/alpha/promcons.c +++ b/sys/arch/alpha/alpha/promcons.c @@ -1,4 +1,4 @@ -/* $OpenBSD: promcons.c,v 1.7 2002/03/14 01:26:26 millert Exp $ */ +/* $OpenBSD: promcons.c,v 1.8 2003/10/03 16:44:46 miod Exp $ */ /* $NetBSD: promcons.c,v 1.5 1996/11/13 22:20:55 cgd Exp $ */ /* @@ -74,9 +74,8 @@ promopen(dev, flag, mode, p) s = spltty(); - if (!prom_tty[unit]) { + if (prom_tty[unit] == NULL) { tp = prom_tty[unit] = ttymalloc(); - tty_attach(tp); } else tp = prom_tty[unit]; diff --git a/sys/arch/alpha/tc/scc.c b/sys/arch/alpha/tc/scc.c index 6832c02a312..82fcc24a18e 100644 --- a/sys/arch/alpha/tc/scc.c +++ b/sys/arch/alpha/tc/scc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: scc.c,v 1.18 2003/06/02 23:27:44 millert Exp $ */ +/* $OpenBSD: scc.c,v 1.19 2003/10/03 16:44:49 miod Exp $ */ /* $NetBSD: scc.c,v 1.58 2002/03/17 19:40:27 atatat Exp $ */ /* @@ -325,8 +325,6 @@ sccattach(parent, self, aux) for (cntr = 0; cntr < 2; cntr++) { pdp->p_addr = (void *)sccaddr; tp = sc->scc_tty[cntr] = ttymalloc(); - if (cntr == 0) - tty_attach(tp); pdp->p_arg = (long)tp; pdp->p_fcn = (void (*)(struct tty*))0; tp->t_dev = (dev_t)((sc->sc_dv.dv_unit << 1) | cntr); @@ -462,7 +460,6 @@ sccopen(dev, flag, mode, p) tp = sc->scc_tty[line]; if (tp == NULL) { tp = sc->scc_tty[line] = ttymalloc(); - tty_attach(tp); } tp->t_oproc = sccstart; tp->t_param = sccparam; diff --git a/sys/arch/hp300/dev/apci.c b/sys/arch/hp300/dev/apci.c index 312e589d1ab..e73f11fd17f 100644 --- a/sys/arch/hp300/dev/apci.c +++ b/sys/arch/hp300/dev/apci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: apci.c,v 1.14 2003/08/15 20:32:12 tedu Exp $ */ +/* $OpenBSD: apci.c,v 1.15 2003/10/03 16:44:49 miod Exp $ */ /* $NetBSD: apci.c,v 1.9 2000/11/02 00:35:05 eeh Exp $ */ /*- @@ -304,7 +304,6 @@ apciopen(dev, flag, mode, p) s = spltty(); if (sc->sc_tty == NULL) { tp = sc->sc_tty = ttymalloc(); - tty_attach(tp); } else tp = sc->sc_tty; splx(s); @@ -439,7 +438,6 @@ apciclose(dev, flag, mode, p) splx(s); ttyclose(tp); #if 0 - tty_detach(tp); ttyfree(tp); sc->sc_tty = NULL; #endif diff --git a/sys/arch/hp300/dev/dca.c b/sys/arch/hp300/dev/dca.c index 922e427ecb1..621c29d40b6 100644 --- a/sys/arch/hp300/dev/dca.c +++ b/sys/arch/hp300/dev/dca.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dca.c,v 1.17 2003/08/15 20:32:12 tedu Exp $ */ +/* $OpenBSD: dca.c,v 1.18 2003/10/03 16:44:49 miod Exp $ */ /* $NetBSD: dca.c,v 1.35 1997/05/05 20:58:18 thorpej Exp $ */ /* @@ -307,7 +307,6 @@ dcaopen(dev, flag, mode, p) s = spltty(); if (sc->sc_tty == NULL) { tp = sc->sc_tty = ttymalloc(); - tty_attach(tp); } else tp = sc->sc_tty; splx(s); @@ -442,7 +441,6 @@ dcaclose(dev, flag, mode, p) splx(s); ttyclose(tp); #if 0 - tty_detach(tp); ttyfree(tp); sc->sc_tty = NULL; #endif diff --git a/sys/arch/hp300/dev/dcm.c b/sys/arch/hp300/dev/dcm.c index 5fe84ec323e..b6a24c95d6a 100644 --- a/sys/arch/hp300/dev/dcm.c +++ b/sys/arch/hp300/dev/dcm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dcm.c,v 1.15 2003/08/15 20:32:13 tedu Exp $ */ +/* $OpenBSD: dcm.c,v 1.16 2003/10/03 16:44:49 miod Exp $ */ /* $NetBSD: dcm.c,v 1.41 1997/05/05 20:59:16 thorpej Exp $ */ /* @@ -452,7 +452,6 @@ dcmopen(dev, flag, mode, p) s = spltty(); if (sc->sc_tty[port] == NULL) { tp = sc->sc_tty[port] = ttymalloc(); - tty_attach(tp); } else tp = sc->sc_tty[port]; splx(s); @@ -587,7 +586,6 @@ dcmclose(dev, flag, mode, p) splx(s); ttyclose(tp); #if 0 - tty_detach(tp); ttyfree(tp); sc->sc_tty[port] == NULL; #endif diff --git a/sys/arch/hp300/dev/ite.c b/sys/arch/hp300/dev/ite.c index 58bd3ed7174..460a1187ac0 100644 --- a/sys/arch/hp300/dev/ite.c +++ b/sys/arch/hp300/dev/ite.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ite.c,v 1.15 2003/06/02 23:27:45 millert Exp $ */ +/* $OpenBSD: ite.c,v 1.16 2003/10/03 16:44:49 miod Exp $ */ /* $NetBSD: ite.c,v 1.38 1997/03/31 07:37:25 scottr Exp $ */ /* @@ -301,7 +301,6 @@ iteopen(dev, mode, devtype, p) if (ip->tty == NULL) { tp = ip->tty = ttymalloc(); - tty_attach(tp); } else tp = ip->tty; if ((tp->t_state&(TS_ISOPEN|TS_XCLUDE)) == (TS_ISOPEN|TS_XCLUDE) @@ -350,7 +349,6 @@ iteclose(dev, flag, mode, p) ttyclose(tp); iteoff(ip, 0); #if 0 - tty_detach(tp); ttyfree(tp); ip->tty = (struct tty *)0; #endif diff --git a/sys/arch/hppa/dev/pdc.c b/sys/arch/hppa/dev/pdc.c index d9e3dd00ba0..4181c5b8e89 100644 --- a/sys/arch/hppa/dev/pdc.c +++ b/sys/arch/hppa/dev/pdc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pdc.c,v 1.25 2003/05/14 23:18:09 miod Exp $ */ +/* $OpenBSD: pdc.c,v 1.26 2003/10/03 16:44:49 miod Exp $ */ /* * Copyright (c) 1998-2002 Michael Shalayeff @@ -205,8 +205,9 @@ pdcopen(dev, flag, mode, p) if (sc->sc_tty) tp = sc->sc_tty; - else - tty_attach(tp = sc->sc_tty = ttymalloc()); + else { + tp = sc->sc_tty = ttymalloc(); + } tp->t_oproc = pdcstart; tp->t_param = pdcparam; diff --git a/sys/arch/i386/isa/pccom.c b/sys/arch/i386/isa/pccom.c index 44ab6d562aa..d5bb57fbf25 100644 --- a/sys/arch/i386/isa/pccom.c +++ b/sys/arch/i386/isa/pccom.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pccom.c,v 1.44 2003/08/15 20:32:13 tedu Exp $ */ +/* $OpenBSD: pccom.c,v 1.45 2003/10/03 16:44:49 miod Exp $ */ /* $NetBSD: com.c,v 1.82.4.1 1996/06/02 09:08:00 mrg Exp $ */ /* @@ -741,7 +741,6 @@ com_detach(self, flags) /* Detach and free the tty. */ if (sc->sc_tty) { - tty_detach(sc->sc_tty); ttyfree(sc->sc_tty); } @@ -817,7 +816,6 @@ comopen(dev, flag, mode, p) s = spltty(); if (!sc->sc_tty) { tp = sc->sc_tty = ttymalloc(); - tty_attach(tp); } else tp = sc->sc_tty; splx(s); diff --git a/sys/arch/mac68k/dev/ite.c b/sys/arch/mac68k/dev/ite.c index 278537ddd6c..bfdd6285158 100644 --- a/sys/arch/mac68k/dev/ite.c +++ b/sys/arch/mac68k/dev/ite.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ite.c,v 1.22 2003/06/02 23:27:48 millert Exp $ */ +/* $OpenBSD: ite.c,v 1.23 2003/10/03 16:44:49 miod Exp $ */ /* $NetBSD: ite.c,v 1.32 1997/02/20 00:23:25 scottr Exp $ */ /* @@ -971,7 +971,6 @@ iteopen(dev, mode, devtype, p) if (ite_tty == NULL) { tp = ite_tty = ttymalloc(); - tty_attach(tp); } else tp = ite_tty; if ((tp->t_state & (TS_ISOPEN | TS_XCLUDE)) == (TS_ISOPEN | TS_XCLUDE) diff --git a/sys/arch/mac68k/dev/z8530tty.c b/sys/arch/mac68k/dev/z8530tty.c index bf4aac4db19..461fbbe1621 100644 --- a/sys/arch/mac68k/dev/z8530tty.c +++ b/sys/arch/mac68k/dev/z8530tty.c @@ -1,4 +1,4 @@ -/* $OpenBSD: z8530tty.c,v 1.13 2003/08/15 20:32:13 tedu Exp $ */ +/* $OpenBSD: z8530tty.c,v 1.14 2003/10/03 16:44:49 miod Exp $ */ /* $NetBSD: z8530tty.c,v 1.10 1996/12/18 05:17:44 scottr Exp $ */ /* @@ -197,7 +197,6 @@ zstty_attach(parent, self, aux) tp->t_hwiflow = zshwiflow; ttychars(tp); bcopy(tp->t_cc, zst->zst_cc, sizeof(tp->t_cc)); - tty_attach(tp); zst->zst_tty = tp; zst->zst_rbhiwat = zstty_rbuf_size; /* impossible value */ diff --git a/sys/arch/macppc/dev/z8530tty.c b/sys/arch/macppc/dev/z8530tty.c index d7698c953f7..39c250433d2 100644 --- a/sys/arch/macppc/dev/z8530tty.c +++ b/sys/arch/macppc/dev/z8530tty.c @@ -1,4 +1,4 @@ -/* $OpenBSD: z8530tty.c,v 1.3 2003/08/15 20:32:13 tedu Exp $ */ +/* $OpenBSD: z8530tty.c,v 1.4 2003/10/03 16:44:49 miod Exp $ */ /* $NetBSD: z8530tty.c,v 1.13 1996/10/16 20:42:14 gwr Exp $ */ /*- @@ -348,7 +348,6 @@ zstty_attach(parent, self, aux) tp->t_oproc = zsstart; tp->t_param = zsparam; tp->t_hwiflow = zshwiflow; - tty_attach(tp); zst->zst_tty = tp; zst->zst_rbuf = malloc(zstty_rbuf_size << 1, M_DEVBUF, M_WAITOK); diff --git a/sys/arch/mvme68k/dev/bugtty.c b/sys/arch/mvme68k/dev/bugtty.c index 5f9e6450009..cf539c37352 100644 --- a/sys/arch/mvme68k/dev/bugtty.c +++ b/sys/arch/mvme68k/dev/bugtty.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bugtty.c,v 1.10 2003/08/15 20:32:14 tedu Exp $ */ +/* $OpenBSD: bugtty.c,v 1.11 2003/10/03 16:44:50 miod Exp $ */ /* * Copyright (c) 1995 Dale Rahn. @@ -171,7 +171,6 @@ bugttyopen(dev, flag, mode, p) tp = bugtty_tty[unit]; } else { tp = bugtty_tty[unit] = ttymalloc(); - tty_attach(tp); } tp->t_oproc = bugttyoutput; tp->t_param = NULL; diff --git a/sys/arch/mvme68k/dev/cl.c b/sys/arch/mvme68k/dev/cl.c index 85693b3dff8..85e710f2af1 100644 --- a/sys/arch/mvme68k/dev/cl.c +++ b/sys/arch/mvme68k/dev/cl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cl.c,v 1.31 2003/08/15 20:32:14 tedu Exp $ */ +/* $OpenBSD: cl.c,v 1.32 2003/10/03 16:44:50 miod Exp $ */ /* * Copyright (c) 1995 Dale Rahn. All rights reserved. @@ -553,7 +553,6 @@ clopen(dev, flag, mode, p) tp = cl->tty; } else { tp = cl->tty = ttymalloc(); - tty_attach(tp); } tp->t_oproc = clstart; tp->t_param = clparam; diff --git a/sys/arch/mvme68k/dev/wl.c b/sys/arch/mvme68k/dev/wl.c index 051cfc23d79..c0dddcfdf72 100644 --- a/sys/arch/mvme68k/dev/wl.c +++ b/sys/arch/mvme68k/dev/wl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: wl.c,v 1.12 2003/08/15 20:32:14 tedu Exp $ */ +/* $OpenBSD: wl.c,v 1.13 2003/10/03 16:44:50 miod Exp $ */ /* * Copyright (c) 1995 Dale Rahn. All rights reserved. @@ -518,7 +518,6 @@ wlopen(dev, flag, mode, p) tp = cl->tty; } else { tp = cl->tty = ttymalloc(); - tty_attach(tp); } tp->t_oproc = clstart; tp->t_param = clparam; diff --git a/sys/arch/mvme68k/dev/zs.c b/sys/arch/mvme68k/dev/zs.c index 3b91f2cac17..3c42abdb6c2 100644 --- a/sys/arch/mvme68k/dev/zs.c +++ b/sys/arch/mvme68k/dev/zs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: zs.c,v 1.13 2003/06/02 05:09:14 deraadt Exp $ */ +/* $OpenBSD: zs.c,v 1.14 2003/10/03 16:44:50 miod Exp $ */ /* * Copyright (c) 2000 Steve Murphree, Jr. @@ -364,7 +364,6 @@ zsopen(dev, flag, mode, p) zp = &sc->sc_zs[zsside(dev)]; if (zp->tty == NULL) { zp->tty = ttymalloc(); - tty_attach(zp->tty); zs_ttydef(zp); if (minor(dev) < NZSLINE) zs_tty[minor(dev)] = zp->tty; diff --git a/sys/arch/mvme88k/dev/cl.c b/sys/arch/mvme88k/dev/cl.c index 4220d2af469..b46f2c14e4b 100644 --- a/sys/arch/mvme88k/dev/cl.c +++ b/sys/arch/mvme88k/dev/cl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cl.c,v 1.30 2003/09/28 14:26:25 miod Exp $ */ +/* $OpenBSD: cl.c,v 1.31 2003/10/03 16:44:50 miod Exp $ */ /* * Copyright (c) 1995 Dale Rahn. All rights reserved. @@ -529,7 +529,6 @@ clopen(dev, flag, mode, p) tp = cl->tty; } else { tp = cl->tty = ttymalloc(); - tty_attach(tp); } tp->t_oproc = clstart; tp->t_param = clparam; diff --git a/sys/arch/mvme88k/dev/dart.c b/sys/arch/mvme88k/dev/dart.c index ae71f410d75..0d355417c49 100644 --- a/sys/arch/mvme88k/dev/dart.c +++ b/sys/arch/mvme88k/dev/dart.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dart.c,v 1.23 2003/09/28 14:26:25 miod Exp $ */ +/* $OpenBSD: dart.c,v 1.24 2003/10/03 16:44:50 miod Exp $ */ /* * Mach Operating System @@ -833,7 +833,6 @@ dartopen (dev, flag, mode, p) tp = dart->tty; } else { tp = dart->tty = ttymalloc(); - tty_attach(tp); simple_lock_init(&dart->t_lock); } diff --git a/sys/arch/sparc/dev/magma.c b/sys/arch/sparc/dev/magma.c index d6c52594442..10744180248 100644 --- a/sys/arch/sparc/dev/magma.c +++ b/sys/arch/sparc/dev/magma.c @@ -1,4 +1,4 @@ -/* $OpenBSD: magma.c,v 1.16 2003/09/23 16:51:11 millert Exp $ */ +/* $OpenBSD: magma.c,v 1.17 2003/10/03 16:44:50 miod Exp $ */ /* * magma.c * @@ -845,8 +845,6 @@ int port, chip, chan; mp->mp_channel = chan; tp = ttymalloc(); - if( tp == NULL ) break; - tty_attach(tp); tp->t_oproc = mtty_start; tp->t_param = mtty_param; diff --git a/sys/arch/sparc/dev/spif.c b/sys/arch/sparc/dev/spif.c index 6642bcc5d81..9cc917732be 100644 --- a/sys/arch/sparc/dev/spif.c +++ b/sys/arch/sparc/dev/spif.c @@ -1,4 +1,4 @@ -/* $OpenBSD: spif.c,v 1.17 2003/09/23 16:51:11 millert Exp $ */ +/* $OpenBSD: spif.c,v 1.18 2003/10/03 16:44:50 miod Exp $ */ /* * Copyright (c) 1999 Jason L. Wright (jason@thought.net) @@ -249,9 +249,6 @@ sttyattach(parent, dev, aux) sc->sc_regs->dtrlatch[port] = 1; tp = ttymalloc(); - if (tp == NULL) - break; - tty_attach(tp); tp->t_oproc = stty_start; tp->t_param = stty_param; diff --git a/sys/arch/sparc/dev/z8530tty.c b/sys/arch/sparc/dev/z8530tty.c index d9e0f119b63..d3ef26a3329 100644 --- a/sys/arch/sparc/dev/z8530tty.c +++ b/sys/arch/sparc/dev/z8530tty.c @@ -1,4 +1,4 @@ -/* $OpenBSD: z8530tty.c,v 1.3 2003/08/15 20:32:14 tedu Exp $ */ +/* $OpenBSD: z8530tty.c,v 1.4 2003/10/03 16:44:50 miod Exp $ */ /* $NetBSD: z8530tty.c,v 1.13 1996/10/16 20:42:14 gwr Exp $ */ /*- @@ -343,7 +343,6 @@ zstty_attach(parent, self, aux) tp->t_oproc = zsstart; tp->t_param = zsparam; tp->t_hwiflow = zshwiflow; - tty_attach(tp); zst->zst_tty = tp; zst->zst_rbuf = malloc(zstty_rbuf_size << 1, M_DEVBUF, M_WAITOK); diff --git a/sys/arch/sparc64/dev/pcons.c b/sys/arch/sparc64/dev/pcons.c index d2a503d0484..147ff99cecb 100644 --- a/sys/arch/sparc64/dev/pcons.c +++ b/sys/arch/sparc64/dev/pcons.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pcons.c,v 1.6 2003/08/15 20:32:15 tedu Exp $ */ +/* $OpenBSD: pcons.c,v 1.7 2003/10/03 16:44:50 miod Exp $ */ /* $NetBSD: pcons.c,v 1.7 2001/05/02 10:32:20 scw Exp $ */ /*- @@ -176,7 +176,6 @@ pconsopen(dev, flag, mode, p) return ENXIO; if (!(tp = sc->of_tty)) { sc->of_tty = tp = ttymalloc(); - tty_attach(tp); } tp->t_oproc = pconsstart; tp->t_param = pconsparam; diff --git a/sys/arch/sparc64/dev/sab.c b/sys/arch/sparc64/dev/sab.c index 14250d7f600..a0475fd0cda 100644 --- a/sys/arch/sparc64/dev/sab.c +++ b/sys/arch/sparc64/dev/sab.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sab.c,v 1.14 2003/08/15 20:32:15 tedu Exp $ */ +/* $OpenBSD: sab.c,v 1.15 2003/10/03 16:44:50 miod Exp $ */ /* * Copyright (c) 2001 Jason L. Wright (jason@thought.net) @@ -377,11 +377,6 @@ sabtty_attach(parent, self, aux) int r; sc->sc_tty = ttymalloc(); - if (sc->sc_tty == NULL) { - printf(": failed to allocate tty\n"); - return; - } - tty_attach(sc->sc_tty); sc->sc_tty->t_oproc = sabtty_start; sc->sc_tty->t_param = sabtty_param; diff --git a/sys/arch/sparc64/dev/z8530tty.c b/sys/arch/sparc64/dev/z8530tty.c index a7c597e22bd..24da5aed7cd 100644 --- a/sys/arch/sparc64/dev/z8530tty.c +++ b/sys/arch/sparc64/dev/z8530tty.c @@ -1,4 +1,4 @@ -/* $OpenBSD: z8530tty.c,v 1.8 2003/08/15 20:32:15 tedu Exp $ */ +/* $OpenBSD: z8530tty.c,v 1.9 2003/10/03 16:44:50 miod Exp $ */ /* $NetBSD: z8530tty.c,v 1.77 2001/05/30 15:24:24 lukem Exp $ */ /*- @@ -340,7 +340,6 @@ zstty_attach(parent, self, aux) tp->t_oproc = zsstart; tp->t_param = zsparam; tp->t_hwiflow = zshwiflow; - tty_attach(tp); zst->zst_tty = tp; zst->zst_rbuf = malloc(zstty_rbuf_size << 1, M_DEVBUF, M_WAITOK); diff --git a/sys/arch/vax/qbus/dl.c b/sys/arch/vax/qbus/dl.c index cf88407cadc..8e04c8c4e43 100644 --- a/sys/arch/vax/qbus/dl.c +++ b/sys/arch/vax/qbus/dl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dl.c,v 1.4 2003/06/02 23:27:58 millert Exp $ */ +/* $OpenBSD: dl.c,v 1.5 2003/10/03 16:44:50 miod Exp $ */ /* $NetBSD: dl.c,v 1.11 2000/01/24 02:40:29 matt Exp $ */ /*- @@ -214,7 +214,6 @@ dl_attach (parent, self, aux) /* Initialize our softc structure. Should be done in open? */ sc->sc_tty = ttymalloc(); - tty_attach(sc->sc_tty); /* Now register the TX & RX interrupt handlers */ uba_intr_establish(ua->ua_icookie, ua->ua_cvec , dlxint, sc); diff --git a/sys/arch/vax/qbus/qd.c b/sys/arch/vax/qbus/qd.c index 8567dda9e1a..0b92dc4e6c9 100644 --- a/sys/arch/vax/qbus/qd.c +++ b/sys/arch/vax/qbus/qd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: qd.c,v 1.7 2003/06/02 23:27:58 millert Exp $ */ +/* $OpenBSD: qd.c,v 1.8 2003/10/03 16:44:50 miod Exp $ */ /* $NetBSD: qd.c,v 1.17 2000/01/24 02:40:29 matt Exp $ */ /*- @@ -830,9 +830,6 @@ qdopen(dev, flag, mode, p) if (qd_tty[minor_dev] == NULL) qd_tty[minor_dev] = ttymalloc(); - if (qd_tty[minor_dev] == NULL) - return ENXIO; - /* * this is the console */ diff --git a/sys/dev/ic/com.c b/sys/dev/ic/com.c index 1d76f57cdfa..c6b39f06882 100644 --- a/sys/dev/ic/com.c +++ b/sys/dev/ic/com.c @@ -1,4 +1,4 @@ -/* $OpenBSD: com.c,v 1.93 2003/09/23 16:51:12 millert Exp $ */ +/* $OpenBSD: com.c,v 1.94 2003/10/03 16:44:51 miod Exp $ */ /* $NetBSD: com.c,v 1.82.4.1 1996/06/02 09:08:00 mrg Exp $ */ /* @@ -403,7 +403,6 @@ com_detach(self, flags) /* Detach and free the tty. */ if (sc->sc_tty) { - tty_detach(sc->sc_tty); ttyfree(sc->sc_tty); } @@ -483,7 +482,6 @@ comopen(dev, flag, mode, p) s = spltty(); if (!sc->sc_tty) { tp = sc->sc_tty = ttymalloc(); - tty_attach(tp); } else tp = sc->sc_tty; splx(s); diff --git a/sys/dev/ic/cy.c b/sys/dev/ic/cy.c index 04fb4d49c20..897e889b369 100644 --- a/sys/dev/ic/cy.c +++ b/sys/dev/ic/cy.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cy.c,v 1.23 2003/08/15 20:32:17 tedu Exp $ */ +/* $OpenBSD: cy.c,v 1.24 2003/10/03 16:44:51 miod Exp $ */ /* * Copyright (c) 1996 Timo Rossi. * All rights reserved. @@ -300,18 +300,11 @@ cyopen(dev, flag, mode, p) s = spltty(); if (cy->cy_tty == NULL) { - if ((cy->cy_tty = ttymalloc()) == NULL) { - splx(s); - printf("%s port %d open: can't allocate tty\n", - sc->sc_dev.dv_xname, port); - return (ENOMEM); - } + cy->cy_tty = ttymalloc(); } splx(s); tp = cy->cy_tty; - tty_attach(tp); - tp = cy->cy_tty; tp->t_oproc = cystart; tp->t_param = cyparam; tp->t_dev = dev; diff --git a/sys/dev/ic/z8530tty.c b/sys/dev/ic/z8530tty.c index c414f09358f..257a86ae3c9 100644 --- a/sys/dev/ic/z8530tty.c +++ b/sys/dev/ic/z8530tty.c @@ -1,4 +1,4 @@ -/* $OpenBSD: z8530tty.c,v 1.13 2003/08/15 20:32:17 tedu Exp $ */ +/* $OpenBSD: z8530tty.c,v 1.14 2003/10/03 16:44:51 miod Exp $ */ /* $NetBSD: z8530tty.c,v 1.13 1996/10/16 20:42:14 gwr Exp $ */ /* @@ -259,7 +259,6 @@ zstty_attach(parent, self, aux) tp->t_oproc = zsstart; tp->t_param = zsparam; tp->t_hwiflow = zshwiflow; - tty_attach(tp); zst->zst_tty = tp; zst->zst_rbhiwat = zstty_rbuf_size; /* impossible value */ diff --git a/sys/dev/pci/cz.c b/sys/dev/pci/cz.c index dfd8bc4bce5..3b3929a1cc3 100644 --- a/sys/dev/pci/cz.c +++ b/sys/dev/pci/cz.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cz.c,v 1.8 2003/08/15 20:32:17 tedu Exp $ */ +/* $OpenBSD: cz.c,v 1.9 2003/10/03 16:44:51 miod Exp $ */ /* $NetBSD: cz.c,v 1.15 2001/01/20 19:10:36 thorpej Exp $ */ /*- @@ -425,7 +425,6 @@ cz_attach(parent, self, aux) (cz->cz_dev.dv_unit * ZFIRM_MAX_CHANNELS) + i); tp->t_oproc = czttystart; tp->t_param = czttyparam; - tty_attach(tp); sc->sc_tty = tp; diff --git a/sys/dev/sbus/magma.c b/sys/dev/sbus/magma.c index 222d1860015..d210b651354 100644 --- a/sys/dev/sbus/magma.c +++ b/sys/dev/sbus/magma.c @@ -1,4 +1,4 @@ -/* $OpenBSD: magma.c,v 1.12 2003/09/23 16:51:12 millert Exp $ */ +/* $OpenBSD: magma.c,v 1.13 2003/10/03 16:44:51 miod Exp $ */ /* * magma.c * @@ -814,9 +814,6 @@ mtty_attach(struct device *parent, struct device *dev, void *args) mp->mp_channel = chan; tp = ttymalloc(); - if (tp == NULL) - break; - tty_attach(tp); tp->t_oproc = mtty_start; tp->t_param = mtty_param; diff --git a/sys/dev/sbus/spif.c b/sys/dev/sbus/spif.c index 1bcbd07e547..b83cf859451 100644 --- a/sys/dev/sbus/spif.c +++ b/sys/dev/sbus/spif.c @@ -1,4 +1,4 @@ -/* $OpenBSD: spif.c,v 1.11 2003/09/23 16:51:12 millert Exp $ */ +/* $OpenBSD: spif.c,v 1.12 2003/10/03 16:44:51 miod Exp $ */ /* * Copyright (c) 1999-2002 Jason L. Wright (jason@thought.net) @@ -312,9 +312,6 @@ sttyattach(parent, dev, aux) DTR_WRITE(sc, port, 0); tp = ttymalloc(); - if (tp == NULL) - break; - tty_attach(tp); tp->t_oproc = stty_start; tp->t_param = stty_param; diff --git a/sys/dev/usb/ucom.c b/sys/dev/usb/ucom.c index 5bfb473a61d..85f48b50e2f 100644 --- a/sys/dev/usb/ucom.c +++ b/sys/dev/usb/ucom.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ucom.c,v 1.19 2003/08/15 20:32:18 tedu Exp $ */ +/* $OpenBSD: ucom.c,v 1.20 2003/10/03 16:44:51 miod Exp $ */ /* $NetBSD: ucom.c,v 1.49 2003/01/01 00:10:25 thorpej Exp $ */ /* @@ -211,8 +211,10 @@ USB_ATTACH(ucom) tp->t_param = ucomparam; sc->sc_tty = tp; +#ifndef __OpenBSD__ DPRINTF(("ucom_attach: tty_attach %p\n", tp)); tty_attach(tp); +#endif #if defined(__NetBSD__) && NRND > 0 rnd_attach_source(&sc->sc_rndsource, USBDEVNAME(sc->sc_dev), @@ -271,7 +273,9 @@ USB_DETACH(ucom) /* Detach and free the tty. */ if (tp != NULL) { +#ifndef __OpenBSD__ tty_detach(tp); +#endif ttyfree(tp); sc->sc_tty = NULL; } diff --git a/sys/dev/wscons/wsdisplay.c b/sys/dev/wscons/wsdisplay.c index b910c825fd3..5d61b70df4d 100644 --- a/sys/dev/wscons/wsdisplay.c +++ b/sys/dev/wscons/wsdisplay.c @@ -1,4 +1,4 @@ -/* $OpenBSD: wsdisplay.c,v 1.51 2003/09/23 16:51:12 millert Exp $ */ +/* $OpenBSD: wsdisplay.c,v 1.52 2003/10/03 16:44:51 miod Exp $ */ /* $NetBSD: wsdisplay.c,v 1.37.4.1 2000/06/30 16:27:53 simonb Exp $ */ /* @@ -315,7 +315,6 @@ wsscreen_attach(sc, console, emul, type, cookie, ccol, crow, defattr) scr->scr_dconf = dconf; scr->scr_tty = ttymalloc(); - tty_attach(scr->scr_tty); scr->scr_hold_screen = 0; if (WSSCREEN_HAS_EMULATOR(scr)) scr->scr_flags = 0; @@ -339,7 +338,6 @@ wsscreen_detach(scr) if (WSSCREEN_HAS_TTY(scr)) { timeout_del(&scr->scr_tty->t_rstrt_to); - tty_detach(scr->scr_tty); ttyfree(scr->scr_tty); } if (WSSCREEN_HAS_EMULATOR(scr)) 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); diff --git a/sys/kern/tty_pty.c b/sys/kern/tty_pty.c index 6cb8615f724..a77c60c108f 100644 --- a/sys/kern/tty_pty.c +++ b/sys/kern/tty_pty.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tty_pty.c,v 1.15 2003/09/23 16:51:12 millert Exp $ */ +/* $OpenBSD: tty_pty.c,v 1.16 2003/10/03 16:44:51 miod Exp $ */ /* $NetBSD: tty_pty.c,v 1.33.4.1 1996/06/02 09:08:11 mrg Exp $ */ /* @@ -116,9 +116,7 @@ ptsopen(dev, flag, devtype, p) pti = &pt_softc[minor(dev)]; if (!pti->pt_tty) { tp = pti->pt_tty = ttymalloc(); - tty_attach(tp); - } - else + } else tp = pti->pt_tty; if ((tp->t_state & TS_ISOPEN) == 0) { tp->t_state |= TS_WOPEN; @@ -312,9 +310,7 @@ ptcopen(dev, flag, devtype, p) pti = &pt_softc[minor(dev)]; if (!pti->pt_tty) { tp = pti->pt_tty = ttymalloc(); - tty_attach(tp); - } - else + } else tp = pti->pt_tty; if (tp->t_oproc) return (EIO); diff --git a/sys/sys/tty.h b/sys/sys/tty.h index 6ea4f7512c4..7a4b7efe7b2 100644 --- a/sys/sys/tty.h +++ b/sys/sys/tty.h @@ -1,4 +1,4 @@ -/* $OpenBSD: tty.h,v 1.15 2003/09/23 16:51:13 millert Exp $ */ +/* $OpenBSD: tty.h,v 1.16 2003/10/03 16:44:51 miod Exp $ */ /* $NetBSD: tty.h,v 1.30.4.1 1996/06/02 09:08:13 mrg Exp $ */ /*- @@ -271,8 +271,6 @@ int ttywait(struct tty *tp); int ttywflush(struct tty *tp); void tty_init(void); -void tty_attach(struct tty *); -void tty_detach(struct tty *); struct tty *ttymalloc(void); void ttyfree(struct tty *); u_char *firstc(struct clist *clp, int *c); |