diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2010-07-02 17:27:02 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2010-07-02 17:27:02 +0000 |
commit | 3e0af5ec85e0fe2f9cb51541466d2567ea534a8f (patch) | |
tree | 98ea4006ae16bfe6a1b3730074d23b083948b395 /sys/dev | |
parent | 4d2486b3dbf3e9ae0c6d38b616a80feed0b5e05a (diff) |
Move common code for waking up writers on a tty into a function.
ok deraadt matthew millert
Diffstat (limited to 'sys/dev')
-rw-r--r-- | sys/dev/ic/com.c | 14 | ||||
-rw-r--r-- | sys/dev/ic/cy.c | 16 | ||||
-rw-r--r-- | sys/dev/ic/z8530tty.c | 10 | ||||
-rw-r--r-- | sys/dev/pci/cz.c | 14 | ||||
-rw-r--r-- | sys/dev/sbus/magma.c | 11 | ||||
-rw-r--r-- | sys/dev/sbus/spif.c | 10 | ||||
-rw-r--r-- | sys/dev/usb/ucom.c | 14 | ||||
-rw-r--r-- | sys/dev/wscons/wsdisplay.c | 10 |
8 files changed, 24 insertions, 75 deletions
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); } |