diff options
Diffstat (limited to 'sys')
37 files changed, 123 insertions, 333 deletions
diff --git a/sys/arch/alpha/alpha/promcons.c b/sys/arch/alpha/alpha/promcons.c index 1705e3085dc..0dda2c26fbe 100644 --- a/sys/arch/alpha/alpha/promcons.c +++ b/sys/arch/alpha/alpha/promcons.c @@ -1,4 +1,4 @@ -/* $OpenBSD: promcons.c,v 1.15 2010/06/28 14:13:25 deraadt Exp $ */ +/* $OpenBSD: promcons.c,v 1.16 2010/07/02 17:27:01 nicm Exp $ */ /* $NetBSD: promcons.c,v 1.5 1996/11/13 22:20:55 cgd Exp $ */ /* @@ -184,13 +184,7 @@ promstart(tp) s = spltty(); if (tp->t_state & (TS_TTSTOP | TS_BUSY)) goto out; - if (tp->t_outq.c_cc <= tp->t_lowat) { - if (tp->t_state & TS_ASLEEP) { - tp->t_state &= ~TS_ASLEEP; - wakeup((caddr_t)&tp->t_outq); - } - selwakeup(&tp->t_wsel); - } + ttwakeupwr(tp); tp->t_state |= TS_BUSY; while (tp->t_outq.c_cc != 0) promcnputc(tp->t_dev, getc(&tp->t_outq)); diff --git a/sys/arch/alpha/tc/scc.c b/sys/arch/alpha/tc/scc.c index cb2dcd3c0b5..d25901ee6b2 100644 --- a/sys/arch/alpha/tc/scc.c +++ b/sys/arch/alpha/tc/scc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: scc.c,v 1.28 2010/06/28 14:13:26 deraadt Exp $ */ +/* $OpenBSD: scc.c,v 1.29 2010/07/02 17:27:01 nicm Exp $ */ /* $NetBSD: scc.c,v 1.58 2002/03/17 19:40:27 atatat Exp $ */ /* @@ -923,13 +923,7 @@ sccstart(tp) s = spltty(); if (tp->t_state & (TS_TIMEOUT|TS_BUSY|TS_TTSTOP)) goto out; - if (tp->t_outq.c_cc <= tp->t_lowat) { - if (tp->t_state & TS_ASLEEP) { - tp->t_state &= ~TS_ASLEEP; - wakeup((caddr_t)&tp->t_outq); - } - selwakeup(&tp->t_wsel); - } + ttwakeupwr(tp); if (tp->t_outq.c_cc == 0) goto out; /* handle console specially */ @@ -942,13 +936,7 @@ sccstart(tp) * After we flush the output queue we may need to wake * up the process that made the output. */ - if (tp->t_outq.c_cc <= tp->t_lowat) { - if (tp->t_state & TS_ASLEEP) { - tp->t_state &= ~TS_ASLEEP; - wakeup((caddr_t)&tp->t_outq); - } - selwakeup(&tp->t_wsel); - } + ttwakeupwr(tp); goto out; } cc = ndqb(&tp->t_outq, 0); diff --git a/sys/arch/aviion/dev/dart.c b/sys/arch/aviion/dev/dart.c index f2be4e0c7d3..0e3bb9dceae 100644 --- a/sys/arch/aviion/dev/dart.c +++ b/sys/arch/aviion/dev/dart.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dart.c,v 1.10 2010/06/28 14:13:27 deraadt Exp $ */ +/* $OpenBSD: dart.c,v 1.11 2010/07/02 17:27:01 nicm Exp $ */ /* * Mach Operating System @@ -262,15 +262,9 @@ dartstart(struct tty *tp) if (tp->t_state & (TS_TIMEOUT | TS_BUSY | TS_TTSTOP)) goto bail; - if (tp->t_outq.c_cc <= tp->t_lowat) { - if (tp->t_state & TS_ASLEEP) { - tp->t_state &= ~TS_ASLEEP; - wakeup((caddr_t)&tp->t_outq); - } - selwakeup(&tp->t_wsel); - if (tp->t_outq.c_cc == 0) - goto bail; - } + ttwakeupwr(tp); + if (tp->t_outq.c_cc == 0) + goto bail; tp->t_state |= TS_BUSY; while (tp->t_outq.c_cc != 0) { diff --git a/sys/arch/hp300/dev/apci.c b/sys/arch/hp300/dev/apci.c index 4e5b9ad65ba..6bc333b4f4d 100644 --- a/sys/arch/hp300/dev/apci.c +++ b/sys/arch/hp300/dev/apci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: apci.c,v 1.40 2010/06/30 18:10:47 miod Exp $ */ +/* $OpenBSD: apci.c,v 1.41 2010/07/02 17:27:01 nicm Exp $ */ /* $NetBSD: apci.c,v 1.9 2000/11/02 00:35:05 eeh Exp $ */ /*- @@ -762,15 +762,9 @@ apcistart(tp) if (tp->t_state & (TS_TIMEOUT|TS_TTSTOP)) goto out; - if (tp->t_outq.c_cc <= tp->t_lowat) { - if (tp->t_state & TS_ASLEEP) { - tp->t_state &= ~TS_ASLEEP; - wakeup((caddr_t)&tp->t_outq); - } - selwakeup(&tp->t_wsel); - if (tp->t_outq.c_cc == 0) - goto out; - } + ttwakeupwr(tp); + if (tp->t_outq.c_cc == 0) + goto out; if (apci->ap_lsr & LSR_TXRDY) { tp->t_state |= TS_BUSY; if (sc->sc_flags & APCI_HASFIFO) { diff --git a/sys/arch/hp300/dev/dca.c b/sys/arch/hp300/dev/dca.c index 2083b880b70..ef2c0a306da 100644 --- a/sys/arch/hp300/dev/dca.c +++ b/sys/arch/hp300/dev/dca.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dca.c,v 1.41 2010/06/30 18:10:47 miod Exp $ */ +/* $OpenBSD: dca.c,v 1.42 2010/07/02 17:27:01 nicm Exp $ */ /* $NetBSD: dca.c,v 1.35 1997/05/05 20:58:18 thorpej Exp $ */ /* @@ -861,15 +861,9 @@ dcastart(tp) if (tp->t_state & (TS_TIMEOUT|TS_TTSTOP)) goto out; - if (tp->t_outq.c_cc <= tp->t_lowat) { - if (tp->t_state & TS_ASLEEP) { - tp->t_state &= ~TS_ASLEEP; - wakeup((caddr_t)&tp->t_outq); - } - selwakeup(&tp->t_wsel); - if (tp->t_outq.c_cc == 0) - goto out; - } + ttwakeupwr(tp); + if (tp->t_outq.c_cc == 0) + goto out; if (dca->dca_lsr & LSR_TXRDY) { tp->t_state |= TS_BUSY; if (sc->sc_flags & DCA_HASFIFO) { diff --git a/sys/arch/hp300/dev/dcm.c b/sys/arch/hp300/dev/dcm.c index 9691f312a2f..3e329fc8ac5 100644 --- a/sys/arch/hp300/dev/dcm.c +++ b/sys/arch/hp300/dev/dcm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dcm.c,v 1.34 2010/06/28 14:13:27 deraadt Exp $ */ +/* $OpenBSD: dcm.c,v 1.35 2010/07/02 17:27:01 nicm Exp $ */ /* $NetBSD: dcm.c,v 1.41 1997/05/05 20:59:16 thorpej Exp $ */ /* @@ -1171,13 +1171,7 @@ dcmstart(tp) #endif if (tp->t_state & (TS_TIMEOUT|TS_BUSY|TS_TTSTOP)) goto out; - if (tp->t_outq.c_cc <= tp->t_lowat) { - if (tp->t_state&TS_ASLEEP) { - tp->t_state &= ~TS_ASLEEP; - wakeup((caddr_t)&tp->t_outq); - } - selwakeup(&tp->t_wsel); - } + ttwakeupwr(tp); if (tp->t_outq.c_cc == 0) { #ifdef DCMSTATS dsp->xempty++; diff --git a/sys/arch/hppa/dev/pdc.c b/sys/arch/hppa/dev/pdc.c index 5a411fa8d89..a2db4651c87 100644 --- a/sys/arch/hppa/dev/pdc.c +++ b/sys/arch/hppa/dev/pdc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pdc.c,v 1.37 2010/06/28 14:13:27 deraadt Exp $ */ +/* $OpenBSD: pdc.c,v 1.38 2010/07/02 17:27:01 nicm Exp $ */ /* * Copyright (c) 1998-2003 Michael Shalayeff @@ -338,13 +338,7 @@ pdcstart(tp) splx(s); return; } - if (tp->t_outq.c_cc <= tp->t_lowat) { - if (tp->t_state & TS_ASLEEP) { - tp->t_state &= ~TS_ASLEEP; - wakeup((caddr_t)&tp->t_outq); - } - selwakeup(&tp->t_wsel); - } + ttwakeupwr(tp); tp->t_state |= TS_BUSY; while (tp->t_outq.c_cc != 0) pdccnputc(tp->t_dev, getc(&tp->t_outq)); diff --git a/sys/arch/hppa64/dev/pdc.c b/sys/arch/hppa64/dev/pdc.c index 6716b95c027..e8608234ee0 100644 --- a/sys/arch/hppa64/dev/pdc.c +++ b/sys/arch/hppa64/dev/pdc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pdc.c,v 1.9 2010/06/28 14:13:28 deraadt Exp $ */ +/* $OpenBSD: pdc.c,v 1.10 2010/07/02 17:27:01 nicm Exp $ */ /* * Copyright (c) 2005 Michael Shalayeff @@ -328,13 +328,7 @@ pdcstart(tp) splx(s); return; } - if (tp->t_outq.c_cc <= tp->t_lowat) { - if (tp->t_state & TS_ASLEEP) { - tp->t_state &= ~TS_ASLEEP; - wakeup((caddr_t)&tp->t_outq); - } - selwakeup(&tp->t_wsel); - } + ttwakeupwr(tp); tp->t_state |= TS_BUSY; while (tp->t_outq.c_cc != 0) pdccnputc(tp->t_dev, getc(&tp->t_outq)); diff --git a/sys/arch/luna88k/dev/siotty.c b/sys/arch/luna88k/dev/siotty.c index 34665475dd5..b6239035ba1 100644 --- a/sys/arch/luna88k/dev/siotty.c +++ b/sys/arch/luna88k/dev/siotty.c @@ -1,4 +1,4 @@ -/* $OpenBSD: siotty.c,v 1.13 2010/06/28 14:13:28 deraadt Exp $ */ +/* $OpenBSD: siotty.c,v 1.14 2010/07/02 17:27:01 nicm Exp $ */ /* $NetBSD: siotty.c,v 1.9 2002/03/17 19:40:43 atatat Exp $ */ /*- @@ -198,13 +198,7 @@ siostart(tp) s = spltty(); if (tp->t_state & (TS_BUSY|TS_TIMEOUT|TS_TTSTOP)) goto out; - if (tp->t_outq.c_cc <= tp->t_lowat) { - if (tp->t_state & TS_ASLEEP) { - tp->t_state &= ~TS_ASLEEP; - wakeup((caddr_t)&tp->t_outq); - } - selwakeup(&tp->t_wsel); - } + ttwakeupwr(tp); if (tp->t_outq.c_cc == 0) goto out; diff --git a/sys/arch/mac68k/dev/z8530tty.c b/sys/arch/mac68k/dev/z8530tty.c index 56a6ac66254..6f856bbbb5b 100644 --- a/sys/arch/mac68k/dev/z8530tty.c +++ b/sys/arch/mac68k/dev/z8530tty.c @@ -1,4 +1,4 @@ -/* $OpenBSD: z8530tty.c,v 1.23 2010/06/28 14:13:28 deraadt Exp $ */ +/* $OpenBSD: z8530tty.c,v 1.24 2010/07/02 17:27:01 nicm Exp $ */ /* $NetBSD: z8530tty.c,v 1.14 1996/12/17 20:42:43 gwr Exp $ */ /* @@ -639,13 +639,7 @@ zsstart(tp) * If there are sleepers, and output has drained below low * water mark, awaken. */ - if (tp->t_outq.c_cc <= tp->t_lowat) { - if (tp->t_state & TS_ASLEEP) { - tp->t_state &= ~TS_ASLEEP; - wakeup((caddr_t)&tp->t_outq); - } - selwakeup(&tp->t_wsel); - } + ttwakeupwr(tp); nch = ndqb(&tp->t_outq, 0); /* XXX */ (void) splzs(); diff --git a/sys/arch/macppc/dev/z8530tty.c b/sys/arch/macppc/dev/z8530tty.c index 2bbaff08527..b0b6e6e66e5 100644 --- a/sys/arch/macppc/dev/z8530tty.c +++ b/sys/arch/macppc/dev/z8530tty.c @@ -1,4 +1,4 @@ -/* $OpenBSD: z8530tty.c,v 1.13 2010/06/28 14:13:29 deraadt Exp $ */ +/* $OpenBSD: z8530tty.c,v 1.14 2010/07/02 17:27:01 nicm Exp $ */ /* $NetBSD: z8530tty.c,v 1.13 1996/10/16 20:42:14 gwr Exp $ */ /*- @@ -781,15 +781,9 @@ zsstart(struct tty *tp) if (zst->zst_tx_stopped) goto out; - if (tp->t_outq.c_cc <= tp->t_lowat) { - if (ISSET(tp->t_state, TS_ASLEEP)) { - CLR(tp->t_state, TS_ASLEEP); - wakeup((caddr_t)&tp->t_outq); - } - selwakeup(&tp->t_wsel); - if (tp->t_outq.c_cc == 0) - goto out; - } + ttwakeupwr(tp); + if (tp->t_outq.c_cc == 0) + goto out; /* Grab the first contiguous region of buffer space. */ { diff --git a/sys/arch/mvme68k/dev/dart.c b/sys/arch/mvme68k/dev/dart.c index 9c2abb5a137..d1e30fcf547 100644 --- a/sys/arch/mvme68k/dev/dart.c +++ b/sys/arch/mvme68k/dev/dart.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dart.c,v 1.7 2010/06/28 14:13:29 deraadt Exp $ */ +/* $OpenBSD: dart.c,v 1.8 2010/07/02 17:27:01 nicm Exp $ */ /* * Mach Operating System @@ -277,15 +277,9 @@ dartstart(struct tty *tp) if (tp->t_state & (TS_TIMEOUT | TS_BUSY | TS_TTSTOP)) goto bail; - if (tp->t_outq.c_cc <= tp->t_lowat) { - if (tp->t_state & TS_ASLEEP) { - tp->t_state &= ~TS_ASLEEP; - wakeup((caddr_t)&tp->t_outq); - } - selwakeup(&tp->t_wsel); - if (tp->t_outq.c_cc == 0) - goto bail; - } + ttwakeupwr(tp); + if (tp->t_outq.c_cc == 0) + goto bail; tp->t_state |= TS_BUSY; while (tp->t_outq.c_cc != 0) { diff --git a/sys/arch/mvme68k/dev/zs.c b/sys/arch/mvme68k/dev/zs.c index 801dbe43a76..71eb8708113 100644 --- a/sys/arch/mvme68k/dev/zs.c +++ b/sys/arch/mvme68k/dev/zs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: zs.c,v 1.33 2010/06/28 14:13:29 deraadt Exp $ */ +/* $OpenBSD: zs.c,v 1.34 2010/07/02 17:27:01 nicm Exp $ */ /* * Copyright (c) 2000 Steve Murphree, Jr. @@ -557,13 +557,7 @@ zsstop(tp, flag) tp->t_state &= ~TS_BUSY; spltty(); ndflush(&tp->t_outq, n); - if (tp->t_outq.c_cc <= tp->t_lowat) { - if (tp->t_state & TS_ASLEEP) { - tp->t_state &= ~TS_ASLEEP; - wakeup((caddr_t) & tp->t_outq); - } - selwakeup(&tp->t_wsel); - } + ttwakeupwr(tp); } splx(s); return (0); @@ -905,13 +899,7 @@ zs_softint(arg) && (tp->t_state & TS_BUSY) != 0) { tp->t_state &= ~(TS_BUSY | TS_FLUSH); ndflush(&tp->t_outq, zp->sent_count); - if (tp->t_outq.c_cc <= tp->t_lowat) { - if (tp->t_state & TS_ASLEEP) { - tp->t_state &= ~TS_ASLEEP; - wakeup((caddr_t) & tp->t_outq); - } - selwakeup(&tp->t_wsel); - } + ttwakeupwr(tp); if (tp->t_line != 0) (*linesw[tp->t_line].l_start) (tp); else diff --git a/sys/arch/mvme88k/dev/dart.c b/sys/arch/mvme88k/dev/dart.c index 689209f8c73..d92e4402204 100644 --- a/sys/arch/mvme88k/dev/dart.c +++ b/sys/arch/mvme88k/dev/dart.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dart.c,v 1.56 2010/06/28 14:13:29 deraadt Exp $ */ +/* $OpenBSD: dart.c,v 1.57 2010/07/02 17:27:01 nicm Exp $ */ /* * Mach Operating System @@ -306,15 +306,9 @@ dartstart(struct tty *tp) if (tp->t_state & (TS_TIMEOUT | TS_BUSY | TS_TTSTOP)) goto bail; - if (tp->t_outq.c_cc <= tp->t_lowat) { - if (tp->t_state & TS_ASLEEP) { - tp->t_state &= ~TS_ASLEEP; - wakeup((caddr_t)&tp->t_outq); - } - selwakeup(&tp->t_wsel); - if (tp->t_outq.c_cc == 0) - goto bail; - } + ttwakeupwr(tp); + if (tp->t_outq.c_cc == 0) + goto bail; tp->t_state |= TS_BUSY; while (tp->t_outq.c_cc != 0) { diff --git a/sys/arch/sh/dev/scif.c b/sys/arch/sh/dev/scif.c index 2163eda9af5..7e832f7678c 100644 --- a/sys/arch/sh/dev/scif.c +++ b/sys/arch/sh/dev/scif.c @@ -1,4 +1,4 @@ -/* $OpenBSD: scif.c,v 1.13 2010/06/28 14:13:30 deraadt Exp $ */ +/* $OpenBSD: scif.c,v 1.14 2010/07/02 17:27:01 nicm Exp $ */ /* $NetBSD: scif.c,v 1.47 2006/07/23 22:06:06 ad Exp $ */ /*- @@ -485,15 +485,9 @@ scifstart(struct tty *tp) if (sc->sc_tx_stopped) goto out; - if (tp->t_outq.c_cc <= tp->t_lowat) { - if (ISSET(tp->t_state, TS_ASLEEP)) { - CLR(tp->t_state, TS_ASLEEP); - wakeup(&tp->t_outq); - } - selwakeup(&tp->t_wsel); - if (tp->t_outq.c_cc == 0) - goto out; - } + ttwakeupwr(tp); + if (tp->t_outq.c_cc == 0) + goto out; /* Grab the first contiguous region of buffer space. */ { diff --git a/sys/arch/sparc/dev/magma.c b/sys/arch/sparc/dev/magma.c index 3209d16bb23..50be93a3f9b 100644 --- a/sys/arch/sparc/dev/magma.c +++ b/sys/arch/sparc/dev/magma.c @@ -1,4 +1,4 @@ -/* $OpenBSD: magma.c,v 1.26 2010/06/28 14:13:30 deraadt Exp $ */ +/* $OpenBSD: magma.c,v 1.27 2010/07/02 17:27:01 nicm Exp $ */ /*- * Copyright (c) 1998 Iain Hibbert @@ -1201,14 +1201,7 @@ mtty_start(tp) * If we are sleeping and output has drained below * low water mark, awaken. */ - if (tp->t_outq.c_cc <= tp->t_lowat) { - if (ISSET(tp->t_state, TS_ASLEEP)) { - CLR(tp->t_state, TS_ASLEEP); - wakeup(&tp->t_outq); - } - - selwakeup(&tp->t_wsel); - } + ttwakeupwr(tp); /* * If there is something to send, start transmitting. diff --git a/sys/arch/sparc/dev/spif.c b/sys/arch/sparc/dev/spif.c index 03fb662aab9..d1324afd83f 100644 --- a/sys/arch/sparc/dev/spif.c +++ b/sys/arch/sparc/dev/spif.c @@ -1,4 +1,4 @@ -/* $OpenBSD: spif.c,v 1.26 2010/06/28 14:13:30 deraadt Exp $ */ +/* $OpenBSD: spif.c,v 1.27 2010/07/02 17:27:01 nicm Exp $ */ /* * Copyright (c) 1999 Jason L. Wright (jason@thought.net) @@ -676,13 +676,7 @@ stty_start(tp) s = spltty(); if (!ISSET(tp->t_state, TS_TTSTOP | TS_TIMEOUT | TS_BUSY)) { - if (tp->t_outq.c_cc <= tp->t_lowat) { - if (ISSET(tp->t_state, TS_ASLEEP)) { - CLR(tp->t_state, TS_ASLEEP); - wakeup(&tp->t_outq); - } - selwakeup(&tp->t_wsel); - } + ttwakeupwr(tp); if (tp->t_outq.c_cc) { sp->sp_txc = ndqb(&tp->t_outq, 0); sp->sp_txp = tp->t_outq.c_cf; diff --git a/sys/arch/sparc/dev/z8530tty.c b/sys/arch/sparc/dev/z8530tty.c index c7765b4ee07..bfb68082ec4 100644 --- a/sys/arch/sparc/dev/z8530tty.c +++ b/sys/arch/sparc/dev/z8530tty.c @@ -1,4 +1,4 @@ -/* $OpenBSD: z8530tty.c,v 1.16 2010/06/28 14:13:30 deraadt Exp $ */ +/* $OpenBSD: z8530tty.c,v 1.17 2010/07/02 17:27:01 nicm Exp $ */ /* $NetBSD: z8530tty.c,v 1.13 1996/10/16 20:42:14 gwr Exp $ */ /*- @@ -878,15 +878,9 @@ zsstart(tp) if (zst->zst_tx_stopped) goto out; - if (tp->t_outq.c_cc <= tp->t_lowat) { - if (ISSET(tp->t_state, TS_ASLEEP)) { - CLR(tp->t_state, TS_ASLEEP); - wakeup((caddr_t)&tp->t_outq); - } - selwakeup(&tp->t_wsel); - if (tp->t_outq.c_cc == 0) - goto out; - } + ttwakeupwr(tp); + if (tp->t_outq.c_cc == 0) + goto out; /* Grab the first contiguous region of buffer space. */ { diff --git a/sys/arch/sparc64/dev/sab.c b/sys/arch/sparc64/dev/sab.c index 12496c4aa5f..abbcbd8b334 100644 --- a/sys/arch/sparc64/dev/sab.c +++ b/sys/arch/sparc64/dev/sab.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sab.c,v 1.29 2010/06/28 14:13:31 deraadt Exp $ */ +/* $OpenBSD: sab.c,v 1.30 2010/07/02 17:27:01 nicm Exp $ */ /* * Copyright (c) 2001 Jason L. Wright (jason@thought.net) @@ -1093,13 +1093,7 @@ sabtty_start(tp) s = spltty(); if ((tp->t_state & (TS_TTSTOP | TS_TIMEOUT | TS_BUSY)) == 0) { - if (tp->t_outq.c_cc <= tp->t_lowat) { - if (tp->t_state & TS_ASLEEP) { - tp->t_state &= ~TS_ASLEEP; - wakeup(&tp->t_outq); - } - selwakeup(&tp->t_wsel); - } + ttwakeupwr(tp); if (tp->t_outq.c_cc) { sc->sc_txc = ndqb(&tp->t_outq, 0); sc->sc_txp = tp->t_outq.c_cf; diff --git a/sys/arch/sparc64/dev/sbbc.c b/sys/arch/sparc64/dev/sbbc.c index d1ea24ad6e3..02d84098bdb 100644 --- a/sys/arch/sparc64/dev/sbbc.c +++ b/sys/arch/sparc64/dev/sbbc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sbbc.c,v 1.9 2010/06/28 14:13:31 deraadt Exp $ */ +/* $OpenBSD: sbbc.c,v 1.10 2010/07/02 17:27:01 nicm Exp $ */ /* * Copyright (c) 2008 Mark Kettenis * @@ -623,13 +623,7 @@ sbbcstart(struct tty *tp) splx(s); return; } - if (tp->t_outq.c_cc <= tp->t_lowat) { - if (tp->t_state & TS_ASLEEP) { - tp->t_state &= ~TS_ASLEEP; - wakeup((caddr_t)&tp->t_outq); - } - selwakeup(&tp->t_wsel); - } + ttwakeupwr(tp); tp->t_state |= TS_BUSY; while (tp->t_outq.c_cc != 0) sbbc_cnputc(tp->t_dev, getc(&tp->t_outq)); diff --git a/sys/arch/sparc64/dev/vcctty.c b/sys/arch/sparc64/dev/vcctty.c index 1d710e71188..b6e5bdceb9d 100644 --- a/sys/arch/sparc64/dev/vcctty.c +++ b/sys/arch/sparc64/dev/vcctty.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vcctty.c,v 1.5 2010/06/28 14:13:31 deraadt Exp $ */ +/* $OpenBSD: vcctty.c,v 1.6 2010/07/02 17:27:01 nicm Exp $ */ /* * Copyright (c) 2009 Mark Kettenis * @@ -434,13 +434,7 @@ vccttystart(struct tty *tp) splx(s); return; } - if (tp->t_outq.c_cc <= tp->t_lowat) { - if (tp->t_state & TS_ASLEEP) { - tp->t_state &= ~TS_ASLEEP; - wakeup((caddr_t)&tp->t_outq); - } - selwakeup(&tp->t_wsel); - } + ttwakeupwr(tp); tp->t_state |= TS_BUSY; while (tp->t_outq.c_cc != 0) vcctty_send_data(sc, getc(&tp->t_outq)); diff --git a/sys/arch/sparc64/dev/vcons.c b/sys/arch/sparc64/dev/vcons.c index 847883a38fb..b72a8272674 100644 --- a/sys/arch/sparc64/dev/vcons.c +++ b/sys/arch/sparc64/dev/vcons.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vcons.c,v 1.9 2010/06/28 14:13:31 deraadt Exp $ */ +/* $OpenBSD: vcons.c,v 1.10 2010/07/02 17:27:01 nicm Exp $ */ /* * Copyright (c) 2008 Mark Kettenis * @@ -274,13 +274,7 @@ vconsstart(struct tty *tp) splx(s); return; } - if (tp->t_outq.c_cc <= tp->t_lowat) { - if (tp->t_state & TS_ASLEEP) { - tp->t_state &= ~TS_ASLEEP; - wakeup((caddr_t)&tp->t_outq); - } - selwakeup(&tp->t_wsel); - } + ttwakeupwr(tp); tp->t_state |= TS_BUSY; while (tp->t_outq.c_cc != 0) vcons_cnputc(tp->t_dev, getc(&tp->t_outq)); diff --git a/sys/arch/sparc64/dev/z8530tty.c b/sys/arch/sparc64/dev/z8530tty.c index c485899c08d..d20f7c3137d 100644 --- a/sys/arch/sparc64/dev/z8530tty.c +++ b/sys/arch/sparc64/dev/z8530tty.c @@ -1,4 +1,4 @@ -/* $OpenBSD: z8530tty.c,v 1.21 2010/06/28 14:13:31 deraadt Exp $ */ +/* $OpenBSD: z8530tty.c,v 1.22 2010/07/02 17:27:01 nicm Exp $ */ /* $NetBSD: z8530tty.c,v 1.77 2001/05/30 15:24:24 lukem Exp $ */ /*- @@ -846,15 +846,9 @@ zsstart(tp) if (zst->zst_tx_stopped) goto out; - if (tp->t_outq.c_cc <= tp->t_lowat) { - if (ISSET(tp->t_state, TS_ASLEEP)) { - CLR(tp->t_state, TS_ASLEEP); - wakeup((caddr_t)&tp->t_outq); - } - selwakeup(&tp->t_wsel); - if (tp->t_outq.c_cc == 0) - goto out; - } + ttwakeupwr(tp); + if (tp->t_outq.c_cc == 0) + goto out; /* Grab the first contiguous region of buffer space. */ { diff --git a/sys/arch/vax/qbus/dhu.c b/sys/arch/vax/qbus/dhu.c index 4704c654201..04b2ee25c24 100644 --- a/sys/arch/vax/qbus/dhu.c +++ b/sys/arch/vax/qbus/dhu.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dhu.c,v 1.17 2010/06/28 14:13:31 deraadt Exp $ */ +/* $OpenBSD: dhu.c,v 1.18 2010/07/02 17:27:01 nicm Exp $ */ /* $NetBSD: dhu.c,v 1.19 2000/06/04 06:17:01 matt Exp $ */ /* * Copyright (c) 2003, Hugh Graham. @@ -639,13 +639,7 @@ dhustart(tp) if (tp->t_state & (TS_TIMEOUT|TS_BUSY|TS_TTSTOP)) goto out; - if (tp->t_outq.c_cc <= tp->t_lowat) { - if (tp->t_state & TS_ASLEEP) { - tp->t_state &= ~TS_ASLEEP; - wakeup((caddr_t)&tp->t_outq); - } - selwakeup(&tp->t_wsel); - } + ttwakeupwr(tp); if (tp->t_outq.c_cc == 0) goto out; cc = ndqb(&tp->t_outq, 0); diff --git a/sys/arch/vax/qbus/dl.c b/sys/arch/vax/qbus/dl.c index f337ce38329..e87ab207c59 100644 --- a/sys/arch/vax/qbus/dl.c +++ b/sys/arch/vax/qbus/dl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dl.c,v 1.11 2010/06/28 14:13:31 deraadt Exp $ */ +/* $OpenBSD: dl.c,v 1.12 2010/07/02 17:27:01 nicm Exp $ */ /* $NetBSD: dl.c,v 1.11 2000/01/24 02:40:29 matt Exp $ */ /*- @@ -456,18 +456,11 @@ dlstart(tp) sc = dl_cd.cd_devs[unit]; s = spltty(); - if (tp->t_state & (TS_TIMEOUT|TS_BUSY|TS_TTSTOP)) - goto out; - if (tp->t_outq.c_cc <= tp->t_lowat) { - if (tp->t_state & TS_ASLEEP) { - tp->t_state &= ~TS_ASLEEP; - wakeup((caddr_t)&tp->t_outq); - } - selwakeup(&tp->t_wsel); - } - if (tp->t_outq.c_cc == 0) - goto out; - + if (tp->t_state & (TS_TIMEOUT|TS_BUSY|TS_TTSTOP)) + goto out; + ttwakeupwr(tp); + if (tp->t_outq.c_cc == 0) + goto out; if (DL_READ_WORD(DL_UBA_XCSR) & DL_XCSR_TX_READY) { tp->t_state |= TS_BUSY; diff --git a/sys/arch/vax/vxt/qsc.c b/sys/arch/vax/vxt/qsc.c index 3e09171455e..9389fe60f3d 100644 --- a/sys/arch/vax/vxt/qsc.c +++ b/sys/arch/vax/vxt/qsc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: qsc.c,v 1.7 2010/06/28 14:13:32 deraadt Exp $ */ +/* $OpenBSD: qsc.c,v 1.8 2010/07/02 17:27:01 nicm Exp $ */ /* * Copyright (c) 2006 Miodrag Vallat. * @@ -345,15 +345,9 @@ qscstart(struct tty *tp) if (tp->t_state & (TS_TIMEOUT | TS_BUSY | TS_TTSTOP)) goto bail; - if (tp->t_outq.c_cc <= tp->t_lowat) { - if (tp->t_state & TS_ASLEEP) { - tp->t_state &= ~TS_ASLEEP; - wakeup((caddr_t)&tp->t_outq); - } - selwakeup(&tp->t_wsel); - if (tp->t_outq.c_cc == 0) - goto bail; - } + ttwakeupwr(tp); + if (tp->t_outq.c_cc == 0) + goto bail; tp->t_state |= TS_BUSY; while (tp->t_outq.c_cc != 0) { diff --git a/sys/dev/ic/com.c b/sys/dev/ic/com.c index 28369ca10fa..de71a6408e5 100644 --- a/sys/dev/ic/com.c +++ b/sys/dev/ic/com.c @@ -1,4 +1,4 @@ -/* $OpenBSD: com.c,v 1.141 2010/06/28 14:13:32 deraadt Exp $ */ +/* $OpenBSD: com.c,v 1.142 2010/07/02 17:27:01 nicm Exp $ */ /* $NetBSD: com.c,v 1.82.4.1 1996/06/02 09:08:00 mrg Exp $ */ /* @@ -884,15 +884,9 @@ comstart(struct tty *tp) goto stopped; if (ISSET(tp->t_cflag, CRTSCTS) && !ISSET(sc->sc_msr, MSR_CTS)) goto stopped; - if (tp->t_outq.c_cc <= tp->t_lowat) { - if (ISSET(tp->t_state, TS_ASLEEP)) { - CLR(tp->t_state, TS_ASLEEP); - wakeup(&tp->t_outq); - } - selwakeup(&tp->t_wsel); - if (tp->t_outq.c_cc == 0) - goto stopped; - } + ttwakeupwr(tp); + if (tp->t_outq.c_cc == 0) + goto stopped; SET(tp->t_state, TS_BUSY); #ifdef COM_PXA2X0 diff --git a/sys/dev/ic/cy.c b/sys/dev/ic/cy.c index 3280a72a846..afc7bef9c5c 100644 --- a/sys/dev/ic/cy.c +++ b/sys/dev/ic/cy.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cy.c,v 1.31 2010/06/28 14:13:32 deraadt Exp $ */ +/* $OpenBSD: cy.c,v 1.32 2010/07/02 17:27:01 nicm Exp $ */ /* * Copyright (c) 1996 Timo Rossi. * All rights reserved. @@ -621,17 +621,9 @@ cystart(tp) #endif if (!ISSET(tp->t_state, TS_TTSTOP | TS_TIMEOUT | TS_BUSY)) { - if (tp->t_outq.c_cc <= tp->t_lowat) { - if (ISSET(tp->t_state, TS_ASLEEP)) { - CLR(tp->t_state, TS_ASLEEP); - wakeup(&tp->t_outq); - } - - selwakeup(&tp->t_wsel); - - if (tp->t_outq.c_cc == 0) - goto out; - } + ttwakeupwr(tp); + if (tp->t_outq.c_cc == 0) + goto out; SET(tp->t_state, TS_BUSY); cy_enable_transmitter(cy); diff --git a/sys/dev/ic/z8530tty.c b/sys/dev/ic/z8530tty.c index 890ca335712..e22122b010d 100644 --- a/sys/dev/ic/z8530tty.c +++ b/sys/dev/ic/z8530tty.c @@ -1,4 +1,4 @@ -/* $OpenBSD: z8530tty.c,v 1.22 2010/06/28 14:13:33 deraadt Exp $ */ +/* $OpenBSD: z8530tty.c,v 1.23 2010/07/02 17:27:01 nicm Exp $ */ /* $NetBSD: z8530tty.c,v 1.13 1996/10/16 20:42:14 gwr Exp $ */ /* @@ -600,13 +600,7 @@ zsstart(tp) * If there are sleepers, and output has drained below low * water mark, awaken. */ - if (tp->t_outq.c_cc <= tp->t_lowat) { - if (tp->t_state & TS_ASLEEP) { - tp->t_state &= ~TS_ASLEEP; - wakeup((caddr_t)&tp->t_outq); - } - selwakeup(&tp->t_wsel); - } + ttwakeupwr(tp); nch = ndqb(&tp->t_outq, 0); /* XXX */ (void) splzs(); diff --git a/sys/dev/pci/cz.c b/sys/dev/pci/cz.c index 99befa0d60e..f51338df5cc 100644 --- a/sys/dev/pci/cz.c +++ b/sys/dev/pci/cz.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cz.c,v 1.17 2010/06/28 14:13:33 deraadt Exp $ */ +/* $OpenBSD: cz.c,v 1.18 2010/07/02 17:27:01 nicm Exp $ */ /* $NetBSD: cz.c,v 1.15 2001/01/20 19:10:36 thorpej Exp $ */ /*- @@ -1480,15 +1480,9 @@ czttystart(struct tty *tp) if (ISSET(tp->t_state, TS_BUSY | TS_TIMEOUT | TS_TTSTOP)) goto out; - if (tp->t_outq.c_cc <= tp->t_lowat) { - if (ISSET(tp->t_state, TS_ASLEEP)) { - CLR(tp->t_state, TS_ASLEEP); - wakeup(&tp->t_outq); - } - selwakeup(&tp->t_wsel); - if (tp->t_outq.c_cc == 0) - goto out; - } + ttwakeupwr(tp); + if (tp->t_outq.c_cc == 0) + goto out; cztty_transmit(sc, tp); out: diff --git a/sys/dev/sbus/magma.c b/sys/dev/sbus/magma.c index 54a3be568e1..063a10f7a95 100644 --- a/sys/dev/sbus/magma.c +++ b/sys/dev/sbus/magma.c @@ -1,4 +1,4 @@ -/* $OpenBSD: magma.c,v 1.22 2010/06/28 14:13:34 deraadt Exp $ */ +/* $OpenBSD: magma.c,v 1.23 2010/07/02 17:27:01 nicm Exp $ */ /*- * Copyright (c) 1998 Iain Hibbert @@ -1116,14 +1116,7 @@ mtty_start(struct tty *tp) /* if we are sleeping and output has drained below * low water mark, awaken */ - if (tp->t_outq.c_cc <= tp->t_lowat) { - if (ISSET(tp->t_state, TS_ASLEEP)) { - CLR(tp->t_state, TS_ASLEEP); - wakeup(&tp->t_outq); - } - - selwakeup(&tp->t_wsel); - } + ttwakeupwr(tp); /* if something to send, start transmitting */ diff --git a/sys/dev/sbus/spif.c b/sys/dev/sbus/spif.c index 75d88e5d9e1..260b8afbcdc 100644 --- a/sys/dev/sbus/spif.c +++ b/sys/dev/sbus/spif.c @@ -1,4 +1,4 @@ -/* $OpenBSD: spif.c,v 1.18 2010/06/28 14:13:34 deraadt Exp $ */ +/* $OpenBSD: spif.c,v 1.19 2010/07/02 17:27:01 nicm Exp $ */ /* * Copyright (c) 1999-2002 Jason L. Wright (jason@thought.net) @@ -740,13 +740,7 @@ stty_start(tp) s = spltty(); if (!ISSET(tp->t_state, TS_TTSTOP | TS_TIMEOUT | TS_BUSY)) { - if (tp->t_outq.c_cc <= tp->t_lowat) { - if (ISSET(tp->t_state, TS_ASLEEP)) { - CLR(tp->t_state, TS_ASLEEP); - wakeup(&tp->t_outq); - } - selwakeup(&tp->t_wsel); - } + ttwakeupwr(tp); if (tp->t_outq.c_cc) { sp->sp_txc = ndqb(&tp->t_outq, 0); sp->sp_txp = tp->t_outq.c_cf; diff --git a/sys/dev/usb/ucom.c b/sys/dev/usb/ucom.c index 6f58bb6bb7e..9a6050170d2 100644 --- a/sys/dev/usb/ucom.c +++ b/sys/dev/usb/ucom.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ucom.c,v 1.49 2010/06/30 09:36:51 nicm Exp $ */ +/* $OpenBSD: ucom.c,v 1.50 2010/07/02 17:27:01 nicm Exp $ */ /* $NetBSD: ucom.c,v 1.49 2003/01/01 00:10:25 thorpej Exp $ */ /* @@ -943,15 +943,9 @@ ucomstart(struct tty *tp) if (sc->sc_tx_stopped) goto out; - if (tp->t_outq.c_cc <= tp->t_lowat) { - if (ISSET(tp->t_state, TS_ASLEEP)) { - CLR(tp->t_state, TS_ASLEEP); - wakeup(&tp->t_outq); - } - selwakeup(&tp->t_wsel); - if (tp->t_outq.c_cc == 0) - goto out; - } + ttwakeupwr(tp); + if (tp->t_outq.c_cc == 0) + goto out; /* Grab the first contiguous region of buffer space. */ data = tp->t_outq.c_cf; diff --git a/sys/dev/wscons/wsdisplay.c b/sys/dev/wscons/wsdisplay.c index 23f6ebc5418..4bffc3b0ce7 100644 --- a/sys/dev/wscons/wsdisplay.c +++ b/sys/dev/wscons/wsdisplay.c @@ -1,4 +1,4 @@ -/* $OpenBSD: wsdisplay.c,v 1.101 2010/07/01 02:33:05 maja Exp $ */ +/* $OpenBSD: wsdisplay.c,v 1.102 2010/07/02 17:27:01 nicm Exp $ */ /* $NetBSD: wsdisplay.c,v 1.82 2005/02/27 00:27:52 perry Exp $ */ /* @@ -1506,14 +1506,8 @@ wsdisplaystart(struct tty *tp) tp->t_state |= TS_TIMEOUT; timeout_add(&tp->t_rstrt_to, (hz > 128) ? (hz / 128) : 1); } - if (tp->t_outq.c_cc <= tp->t_lowat) { low: - if (tp->t_state & TS_ASLEEP) { - tp->t_state &= ~TS_ASLEEP; - wakeup((caddr_t)&tp->t_outq); - } - selwakeup(&tp->t_wsel); - } + ttwakeupwr(tp); splx(s); } diff --git a/sys/kern/tty.c b/sys/kern/tty.c index b83cec50834..d946e0d11cd 100644 --- a/sys/kern/tty.c +++ b/sys/kern/tty.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tty.c,v 1.86 2010/06/28 14:13:35 deraadt Exp $ */ +/* $OpenBSD: tty.c,v 1.87 2010/07/02 17:27:01 nicm Exp $ */ /* $NetBSD: tty.c,v 1.68.4.2 1996/06/06 16:04:52 thorpej Exp $ */ /*- @@ -2010,6 +2010,22 @@ ttyecho(int c, struct tty *tp) } /* + * Wakeup any writers if necessary. + */ +void +ttwakeupwr(struct tty *tp) +{ + + if (tp->t_outq.c_cc <= tp->t_lowat) { + if (ISSET(tp->t_state, TS_ASLEEP)) { + CLR(tp->t_state, TS_ASLEEP); + wakeup(&tp->t_outq); + } + selwakeup(&tp->t_wsel); + } +} + +/* * Wake up any readers on a tty. */ void diff --git a/sys/kern/tty_pty.c b/sys/kern/tty_pty.c index 16e63e2a12e..9e4d0135cd7 100644 --- a/sys/kern/tty_pty.c +++ b/sys/kern/tty_pty.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tty_pty.c,v 1.46 2010/06/28 14:13:36 deraadt Exp $ */ +/* $OpenBSD: tty_pty.c,v 1.47 2010/07/02 17:27:01 nicm Exp $ */ /* $NetBSD: tty_pty.c,v 1.33.4.1 1996/06/02 09:08:11 mrg Exp $ */ /* @@ -502,13 +502,7 @@ ptcread(dev_t dev, struct uio *uio, int flag) break; error = uiomove(buf, cc, uio); } - if (tp->t_outq.c_cc <= tp->t_lowat) { - if (tp->t_state&TS_ASLEEP) { - tp->t_state &= ~TS_ASLEEP; - wakeup(&tp->t_outq); - } - selwakeup(&tp->t_wsel); - } + ttwakeupwr(tp); if (bufcc) bzero(buf, bufcc); return (error); diff --git a/sys/sys/tty.h b/sys/sys/tty.h index 8d73baafb5b..98d046311aa 100644 --- a/sys/sys/tty.h +++ b/sys/sys/tty.h @@ -1,4 +1,4 @@ -/* $OpenBSD: tty.h,v 1.26 2010/06/30 20:38:50 tedu Exp $ */ +/* $OpenBSD: tty.h,v 1.27 2010/07/02 17:27:01 nicm Exp $ */ /* $NetBSD: tty.h,v 1.30.4.1 1996/06/02 09:08:13 mrg Exp $ */ /*- @@ -274,6 +274,7 @@ int ttkqfilter(dev_t dev, struct knote *kn); void ttsetwater(struct tty *tp); int ttspeedtab(int speed, const struct speedtab *table); int ttstart(struct tty *tp); +void ttwakeupwr(struct tty *tp); void ttwakeup(struct tty *tp); int ttwrite(struct tty *tp, struct uio *uio, int flag); void ttychars(struct tty *tp); |