summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authorad <ad@NetBSD.org>2007-11-19 18:51:36 +0000
committerad <ad@NetBSD.org>2007-11-19 18:51:36 +0000
commitdc26833bb6ee7a7db1d754e75be908943c06df13 (patch)
treef7cbb2593a42316e7bda2f70d8fa4f59c39fb17d /sys/dev
parent417cd168ee1056abd531715a8ac3fde2fb191357 (diff)
- Factor out too many copies of the same bit of tty code.
- Fix another tty signalling/wakeup problem.
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/arcbios/arcbios_tty.c12
-rw-r--r--sys/dev/dec/dz.c20
-rw-r--r--sys/dev/hpc/biconsdev.c13
-rw-r--r--sys/dev/ic/cd18xx.c15
-rw-r--r--sys/dev/ic/clmpcc.c13
-rw-r--r--sys/dev/ic/com.c16
-rw-r--r--sys/dev/ic/cy.c16
-rw-r--r--sys/dev/ic/z8530tty.c16
-rw-r--r--sys/dev/ir/irframe_tty.c5
-rw-r--r--sys/dev/marvell/gtmpsc.c15
-rw-r--r--sys/dev/ofw/ofcons.c15
-rw-r--r--sys/dev/pci/cz.c17
-rw-r--r--sys/dev/qbus/dhu.c15
-rw-r--r--sys/dev/qbus/dl.c17
-rw-r--r--sys/dev/qbus/qd.c16
-rw-r--r--sys/dev/rcons/rcons_kern.c13
-rw-r--r--sys/dev/sbus/magma.c21
-rw-r--r--sys/dev/sbus/spif.c13
-rw-r--r--sys/dev/usb/ucom.c15
-rw-r--r--sys/dev/usb/ucycom.c15
-rw-r--r--sys/dev/wscons/wsdisplay.c13
21 files changed, 73 insertions, 238 deletions
diff --git a/sys/dev/arcbios/arcbios_tty.c b/sys/dev/arcbios/arcbios_tty.c
index 70ebb563aba..04b755ab699 100644
--- a/sys/dev/arcbios/arcbios_tty.c
+++ b/sys/dev/arcbios/arcbios_tty.c
@@ -1,4 +1,4 @@
-/* $NetBSD: arcbios_tty.c,v 1.18 2007/07/11 21:19:08 ad Exp $ */
+/* $NetBSD: arcbios_tty.c,v 1.19 2007/11/19 18:51:45 ad Exp $ */
/*
* Copyright (c) 1994, 1995, 1996 Carnegie-Mellon University.
@@ -28,7 +28,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: arcbios_tty.c,v 1.18 2007/07/11 21:19:08 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: arcbios_tty.c,v 1.19 2007/11/19 18:51:45 ad Exp $");
#include <sys/param.h>
#include <sys/user.h>
@@ -189,13 +189,7 @@ arcbios_tty_start(struct tty *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((void *)&tp->t_outq);
- }
- selwakeup(&tp->t_wsel);
- }
+ ttypull(tp);
tp->t_state |= TS_BUSY;
while (tp->t_outq.c_cc != 0) {
(*ARCBIOS->Write)(ARCBIOS_STDOUT, tp->t_outq.c_cf,
diff --git a/sys/dev/dec/dz.c b/sys/dev/dec/dz.c
index f0889641d35..3256049cc8c 100644
--- a/sys/dev/dec/dz.c
+++ b/sys/dev/dec/dz.c
@@ -1,4 +1,4 @@
-/* $NetBSD: dz.c,v 1.31 2007/11/07 15:56:14 ad Exp $ */
+/* $NetBSD: dz.c,v 1.32 2007/11/19 18:51:46 ad Exp $ */
/*
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
@@ -67,7 +67,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: dz.c,v 1.31 2007/11/07 15:56:14 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dz.c,v 1.32 2007/11/19 18:51:46 ad Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -271,7 +271,7 @@ dzrint(void *arg)
cn_check_magic(tp->t_dev, mcc, dz_cnm_state);
if (!(tp->t_state & TS_ISOPEN)) {
- wakeup((void *)&tp->t_rawq);
+ clwakeup(&tp->t_rawq);
continue;
}
@@ -584,21 +584,9 @@ dzstart(struct tty *tp)
splx(s);
return;
}
- cl = &tp->t_outq;
- if (cl->c_cc <= tp->t_lowat) {
- if (tp->t_state & TS_ASLEEP) {
- tp->t_state &= ~TS_ASLEEP;
- wakeup((void *)cl);
- }
- selwakeup(&tp->t_wsel);
- }
- if (cl->c_cc == 0) {
- splx(s);
+ if (!ttypull(tp))
return;
- }
-
tp->t_state |= TS_BUSY;
-
state = dz_read2(sc, sc->sc_dr.dr_tcrw) & 255;
if ((state & (1 << line)) == 0)
dz_write1(sc, sc->sc_dr.dr_tcr, state | (1 << line));
diff --git a/sys/dev/hpc/biconsdev.c b/sys/dev/hpc/biconsdev.c
index 9810f113a7e..4f6f0a63519 100644
--- a/sys/dev/hpc/biconsdev.c
+++ b/sys/dev/hpc/biconsdev.c
@@ -1,4 +1,4 @@
-/* $NetBSD: biconsdev.c,v 1.19 2007/10/18 18:55:00 joerg Exp $ */
+/* $NetBSD: biconsdev.c,v 1.20 2007/11/19 18:51:46 ad Exp $ */
/*-
* Copyright (c) 1999-2001
@@ -67,7 +67,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: biconsdev.c,v 1.19 2007/10/18 18:55:00 joerg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: biconsdev.c,v 1.20 2007/11/19 18:51:46 ad Exp $");
#include "biconsdev.h"
#include <sys/param.h>
@@ -149,17 +149,10 @@ biconsdev_output(struct tty *tp)
s = spltty();
tp->t_state &= ~TS_BUSY;
/* Come back if there's more to do */
- if (tp->t_outq.c_cc) {
+ if (ttypull(tp)) {
tp->t_state |= TS_TIMEOUT;
callout_schedule(&tp->t_rstrt_ch, 1);
}
- if (tp->t_outq.c_cc <= tp->t_lowat) {
- if (tp->t_state&TS_ASLEEP) {
- tp->t_state &= ~TS_ASLEEP;
- wakeup((void *)&tp->t_outq);
- }
- selwakeup(&tp->t_wsel);
- }
splx(s);
}
diff --git a/sys/dev/ic/cd18xx.c b/sys/dev/ic/cd18xx.c
index 9c36ccb11df..8961d2282f5 100644
--- a/sys/dev/ic/cd18xx.c
+++ b/sys/dev/ic/cd18xx.c
@@ -1,4 +1,4 @@
-/* $NetBSD: cd18xx.c,v 1.21 2007/10/19 11:59:49 ad Exp $ */
+/* $NetBSD: cd18xx.c,v 1.22 2007/11/19 18:51:46 ad Exp $ */
/* XXXad does this even compile? */
@@ -103,7 +103,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cd18xx.c,v 1.21 2007/10/19 11:59:49 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cd18xx.c,v 1.22 2007/11/19 18:51:46 ad Exp $");
#include <sys/param.h>
#include <sys/conf.h>
@@ -689,15 +689,8 @@ cdttystart(tp)
if (p->p_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((void *)&tp->t_outq);
- }
- selwakeup(&tp->t_wsel);
- if (tp->t_outq.c_cc == 0)
- goto out;
- }
+ if (!ttypull(tp))
+ goto out;
/* Grab the first contiguous region of buffer space. */
{
diff --git a/sys/dev/ic/clmpcc.c b/sys/dev/ic/clmpcc.c
index 4cd89b9a649..461aaacbcbc 100644
--- a/sys/dev/ic/clmpcc.c
+++ b/sys/dev/ic/clmpcc.c
@@ -1,4 +1,4 @@
-/* $NetBSD: clmpcc.c,v 1.35 2007/10/19 11:59:49 ad Exp $ */
+/* $NetBSD: clmpcc.c,v 1.36 2007/11/19 18:51:47 ad Exp $ */
/*-
* Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -41,7 +41,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: clmpcc.c,v 1.35 2007/10/19 11:59:49 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: clmpcc.c,v 1.36 2007/11/19 18:51:47 ad Exp $");
#include "opt_ddb.h"
@@ -1050,14 +1050,7 @@ clmpcc_start(tp)
s = spltty();
if ( ISCLR(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);
- }
-
+ ttypull(tp);
if ( ISSET(ch->ch_flags, CLMPCC_FLG_START_BREAK |
CLMPCC_FLG_END_BREAK) ||
tp->t_outq.c_cc > 0 ) {
diff --git a/sys/dev/ic/com.c b/sys/dev/ic/com.c
index ae4bc92687f..f84152b9dff 100644
--- a/sys/dev/ic/com.c
+++ b/sys/dev/ic/com.c
@@ -1,4 +1,4 @@
-/* $NetBSD: com.c,v 1.265 2007/10/19 11:59:49 ad Exp $ */
+/* $NetBSD: com.c,v 1.266 2007/11/19 18:51:47 ad Exp $ */
/*-
* Copyright (c) 1998, 1999, 2004 The NetBSD Foundation, Inc.
@@ -73,7 +73,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: com.c,v 1.265 2007/10/19 11:59:49 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: com.c,v 1.266 2007/11/19 18:51:47 ad Exp $");
#include "opt_com.h"
#include "opt_ddb.h"
@@ -1660,16 +1660,8 @@ comstart(struct tty *tp)
goto out;
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;
- }
+ if (!ttypull(tp))
+ goto out;
/* Grab the first contiguous region of buffer space. */
{
diff --git a/sys/dev/ic/cy.c b/sys/dev/ic/cy.c
index 23d5a9c146e..f33108d931e 100644
--- a/sys/dev/ic/cy.c
+++ b/sys/dev/ic/cy.c
@@ -1,4 +1,4 @@
-/* $NetBSD: cy.c,v 1.53 2007/11/07 15:56:14 ad Exp $ */
+/* $NetBSD: cy.c,v 1.54 2007/11/19 18:51:47 ad Exp $ */
/*
* cy.c
@@ -16,7 +16,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cy.c,v 1.53 2007/11/07 15:56:14 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cy.c,v 1.54 2007/11/19 18:51:47 ad Exp $");
#include <sys/param.h>
#include <sys/ioctl.h>
@@ -593,16 +593,8 @@ cystart(struct tty *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;
- }
+ if (!ttypull(tp))
+ goto out;
SET(tp->t_state, TS_BUSY);
cy_enable_transmitter(sc, cy);
}
diff --git a/sys/dev/ic/z8530tty.c b/sys/dev/ic/z8530tty.c
index 3f12d4c25bd..a72aed74127 100644
--- a/sys/dev/ic/z8530tty.c
+++ b/sys/dev/ic/z8530tty.c
@@ -1,4 +1,4 @@
-/* $NetBSD: z8530tty.c,v 1.116 2007/11/10 18:07:53 ad Exp $ */
+/* $NetBSD: z8530tty.c,v 1.117 2007/11/19 18:51:48 ad Exp $ */
/*-
* Copyright (c) 1993, 1994, 1995, 1996, 1997, 1998, 1999
@@ -137,7 +137,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: z8530tty.c,v 1.116 2007/11/10 18:07:53 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: z8530tty.c,v 1.117 2007/11/19 18:51:48 ad Exp $");
#include "opt_kgdb.h"
#include "opt_ntp.h"
@@ -1052,16 +1052,8 @@ zsstart(tp)
return;
if (zst->zst_tx_stopped)
return;
-
- if (tp->t_outq.c_cc <= tp->t_lowat) {
- if (ISSET(tp->t_state, TS_ASLEEP)) {
- CLR(tp->t_state, TS_ASLEEP);
- cv_broadcast(&tp->t_outq.c_cv);
- }
- selwakeup(&tp->t_wsel);
- if (tp->t_outq.c_cc == 0)
- return;
- }
+ if (!ttypull(tp))
+ return;
/* Grab the first contiguous region of buffer space. */
tba = tp->t_outq.c_cf;
diff --git a/sys/dev/ir/irframe_tty.c b/sys/dev/ir/irframe_tty.c
index b0ea843551f..c57226ebe33 100644
--- a/sys/dev/ir/irframe_tty.c
+++ b/sys/dev/ir/irframe_tty.c
@@ -1,4 +1,4 @@
-/* $NetBSD: irframe_tty.c,v 1.46 2007/11/10 18:29:37 ad Exp $ */
+/* $NetBSD: irframe_tty.c,v 1.47 2007/11/19 18:51:48 ad Exp $ */
/*
* TODO
@@ -48,7 +48,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: irframe_tty.c,v 1.46 2007/11/10 18:29:37 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: irframe_tty.c,v 1.47 2007/11/19 18:51:48 ad Exp $");
#include <sys/param.h>
#include <sys/proc.h>
@@ -650,7 +650,6 @@ irt_putc(struct tty *tp, int c)
mutex_spin_exit(&tty_lock);
goto go;
}
- SET(tp->t_state, TS_ASLEEP);
error = ttysleep(tp, &tp->t_outq.c_cv, true, 0);
mutex_spin_exit(&tty_lock);
if (error)
diff --git a/sys/dev/marvell/gtmpsc.c b/sys/dev/marvell/gtmpsc.c
index 30bd78368fb..37501a80dd6 100644
--- a/sys/dev/marvell/gtmpsc.c
+++ b/sys/dev/marvell/gtmpsc.c
@@ -1,4 +1,4 @@
-/* $NetBSD: gtmpsc.c,v 1.26 2007/10/19 12:00:33 ad Exp $ */
+/* $NetBSD: gtmpsc.c,v 1.27 2007/11/19 18:51:48 ad Exp $ */
/*
* Copyright (c) 2002 Allegro Networks, Inc., Wasabi Systems, Inc.
@@ -45,7 +45,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: gtmpsc.c,v 1.26 2007/10/19 12:00:33 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: gtmpsc.c,v 1.27 2007/11/19 18:51:48 ad Exp $");
#include "opt_kgdb.h"
@@ -768,15 +768,8 @@ gtmpscstart(struct tty *tp)
goto out;
if (sc->sc_tx_stopped)
goto out;
- if (tp->t_outq.c_cc <= tp->t_lowat) {
- if ((tp->t_state & TS_ASLEEP) != 0) {
- tp->t_state &= ~TS_ASLEEP;
- wakeup(&tp->t_outq);
- }
- selwakeup(&tp->t_wsel);
- if (tp->t_outq.c_cc == 0)
- goto out;
- }
+ if (!ttypull(tp))
+ goto out;
/* Grab the first contiguous region of buffer space. */
tba = tp->t_outq.c_cf;
diff --git a/sys/dev/ofw/ofcons.c b/sys/dev/ofw/ofcons.c
index d3f6730ebdd..2740e4f69e7 100644
--- a/sys/dev/ofw/ofcons.c
+++ b/sys/dev/ofw/ofcons.c
@@ -1,4 +1,4 @@
-/* $NetBSD: ofcons.c,v 1.32 2007/10/18 18:55:00 joerg Exp $ */
+/* $NetBSD: ofcons.c,v 1.33 2007/11/19 18:51:48 ad Exp $ */
/*
* Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ofcons.c,v 1.32 2007/10/18 18:55:00 joerg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ofcons.c,v 1.33 2007/11/19 18:51:48 ad Exp $");
#include <sys/param.h>
#include <sys/conf.h>
@@ -240,7 +240,6 @@ static void
ofcons_start(tp)
struct tty *tp;
{
- struct clist *cl;
int s, len;
u_char buf[OFBURSTLEN];
@@ -251,22 +250,14 @@ ofcons_start(tp)
}
tp->t_state |= TS_BUSY;
splx(s);
- cl = &tp->t_outq;
len = q_to_b(cl, buf, OFBURSTLEN);
OF_write(stdout, buf, len);
s = spltty();
tp->t_state &= ~TS_BUSY;
- if (cl->c_cc) {
+ if (ttypull(tp)) {
tp->t_state |= TS_TIMEOUT;
callout_schedule(&tp->t_rstrt_ch, 1);
}
- if (cl->c_cc <= tp->t_lowat) {
- if (tp->t_state & TS_ASLEEP) {
- tp->t_state &= ~TS_ASLEEP;
- wakeup(cl);
- }
- selwakeup(&tp->t_wsel);
- }
splx(s);
}
diff --git a/sys/dev/pci/cz.c b/sys/dev/pci/cz.c
index 620ac359792..9f13ea403fc 100644
--- a/sys/dev/pci/cz.c
+++ b/sys/dev/pci/cz.c
@@ -1,4 +1,4 @@
-/* $NetBSD: cz.c,v 1.46 2007/11/12 14:20:41 ad Exp $ */
+/* $NetBSD: cz.c,v 1.47 2007/11/19 18:51:49 ad Exp $ */
/*-
* Copyright (c) 2000 Zembu Labs, Inc.
@@ -73,7 +73,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cz.c,v 1.46 2007/11/12 14:20:41 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cz.c,v 1.47 2007/11/19 18:51:49 ad Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -1481,17 +1481,8 @@ czttystart(struct tty *tp)
s = spltty();
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;
- }
-
+ if (!ttypull(tp))
+ goto out;
cztty_transmit(sc, tp);
out:
splx(s);
diff --git a/sys/dev/qbus/dhu.c b/sys/dev/qbus/dhu.c
index f5297358fa5..0f67db54688 100644
--- a/sys/dev/qbus/dhu.c
+++ b/sys/dev/qbus/dhu.c
@@ -1,4 +1,4 @@
-/* $NetBSD: dhu.c,v 1.49 2007/11/07 15:56:21 ad Exp $ */
+/* $NetBSD: dhu.c,v 1.50 2007/11/19 18:51:49 ad Exp $ */
/*
* Copyright (c) 2003, Hugh Graham.
* Copyright (c) 1992, 1993
@@ -68,7 +68,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: dhu.c,v 1.49 2007/11/07 15:56:21 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dhu.c,v 1.50 2007/11/19 18:51:49 ad Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -358,7 +358,7 @@ dhurint(arg)
}
if (!(tp->t_state & TS_ISOPEN)) {
- wakeup((void *)&tp->t_rawq);
+ clwakeup(&tp->t_rawq);
continue;
}
@@ -685,14 +685,7 @@ dhustart(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((void *)&tp->t_outq);
- }
- selwakeup(&tp->t_wsel);
- }
- if (tp->t_outq.c_cc == 0)
+ if (!ttypull(tp))
goto out;
cc = ndqb(&tp->t_outq, 0);
if (cc == 0)
diff --git a/sys/dev/qbus/dl.c b/sys/dev/qbus/dl.c
index 7f559be0677..77e2162d4b0 100644
--- a/sys/dev/qbus/dl.c
+++ b/sys/dev/qbus/dl.c
@@ -1,4 +1,4 @@
-/* $NetBSD: dl.c,v 1.38 2007/10/19 12:01:08 ad Exp $ */
+/* $NetBSD: dl.c,v 1.39 2007/11/19 18:51:49 ad Exp $ */
/*-
* Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
@@ -111,7 +111,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: dl.c,v 1.38 2007/10/19 12:01:08 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dl.c,v 1.39 2007/11/19 18:51:49 ad Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -283,7 +283,7 @@ dlrint(void *arg)
cc = c & 0xFF;
if (!(tp->t_state & TS_ISOPEN)) {
- wakeup((void *)&tp->t_rawq);
+ clwakeup(&tp->t_rawq);
return;
}
@@ -468,17 +468,8 @@ dlstart(struct tty *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((void *)&tp->t_outq);
- }
- selwakeup(&tp->t_wsel);
- }
- if (tp->t_outq.c_cc == 0)
+ if (!ttypull(tp))
goto out;
-
-
if (DL_READ_WORD(DL_UBA_XCSR) & DL_XCSR_TX_READY) {
tp->t_state |= TS_BUSY;
DL_WRITE_BYTE(DL_UBA_XBUFL, getc(&tp->t_outq));
diff --git a/sys/dev/qbus/qd.c b/sys/dev/qbus/qd.c
index e0629d6c62e..359713bdd1a 100644
--- a/sys/dev/qbus/qd.c
+++ b/sys/dev/qbus/qd.c
@@ -1,4 +1,4 @@
-/* $NetBSD: qd.c,v 1.39 2007/10/19 12:01:09 ad Exp $ */
+/* $NetBSD: qd.c,v 1.40 2007/11/19 18:51:49 ad Exp $ */
/*-
* Copyright (c) 1988 Regents of the University of California.
@@ -58,7 +58,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: qd.c,v 1.39 2007/10/19 12:01:09 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: qd.c,v 1.40 2007/11/19 18:51:49 ad Exp $");
#include "opt_ddb.h"
@@ -1808,17 +1808,7 @@ void qdstart(tp)
if (unit == 0)
blitc(which_unit, (u_char)c);
}
- /*
- * If there are sleepers, and output has drained below low
- * water mark, wake up the sleepers.
- */
- if (tp->t_outq.c_cc <= tp->t_lowat) {
- if (tp->t_state & TS_ASLEEP){
- tp->t_state &= ~TS_ASLEEP;
- wakeup((void *) &tp->t_outq);
- }
- }
-
+ ttypull(tp);
tp->t_state &= ~TS_BUSY;
out:
diff --git a/sys/dev/rcons/rcons_kern.c b/sys/dev/rcons/rcons_kern.c
index d4adb982935..10dbc7aba86 100644
--- a/sys/dev/rcons/rcons_kern.c
+++ b/sys/dev/rcons/rcons_kern.c
@@ -1,4 +1,4 @@
-/* $NetBSD: rcons_kern.c,v 1.20 2007/10/18 18:55:00 joerg Exp $ */
+/* $NetBSD: rcons_kern.c,v 1.21 2007/11/19 18:51:50 ad Exp $ */
/*
* Copyright (c) 1991, 1993
@@ -41,7 +41,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rcons_kern.c,v 1.20 2007/10/18 18:55:00 joerg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rcons_kern.c,v 1.21 2007/11/19 18:51:50 ad Exp $");
#include <sys/param.h>
#include <sys/device.h>
@@ -101,17 +101,10 @@ rcons_output(tp)
s = spltty();
tp->t_state &= ~TS_BUSY;
/* Come back if there's more to do */
- if (tp->t_outq.c_cc) {
+ if (ttypull(tp)) {
tp->t_state |= TS_TIMEOUT;
callout_schedule(&tp->t_rstrt_ch, 1);
}
- if (tp->t_outq.c_cc <= tp->t_lowat) {
- if (tp->t_state&TS_ASLEEP) {
- tp->t_state &= ~TS_ASLEEP;
- wakeup((void *)&tp->t_outq);
- }
- selwakeup(&tp->t_wsel);
- }
splx(s);
}
diff --git a/sys/dev/sbus/magma.c b/sys/dev/sbus/magma.c
index 2e7598ebbef..3eea09ef0a2 100644
--- a/sys/dev/sbus/magma.c
+++ b/sys/dev/sbus/magma.c
@@ -1,4 +1,4 @@
-/* $NetBSD: magma.c,v 1.44 2007/10/19 12:01:12 ad Exp $ */
+/* $NetBSD: magma.c,v 1.45 2007/11/19 18:51:50 ad Exp $ */
/*
* magma.c
*
@@ -38,7 +38,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: magma.c,v 1.44 2007/10/19 12:01:12 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: magma.c,v 1.45 2007/11/19 18:51:50 ad Exp $");
#if 0
#define MAGMA_DEBUG
@@ -1224,22 +1224,7 @@ mtty_start(tp)
* or delaying or stopped
*/
if( !ISSET(tp->t_state, TS_TTSTOP | TS_TIMEOUT | TS_BUSY) ) {
-
- /* 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);
- }
-
- /* if something to send, start transmitting
- */
- if( tp->t_outq.c_cc ) {
+ if (ttypull(tp)) {
mp->mp_txc = ndqb(&tp->t_outq, 0);
mp->mp_txp = tp->t_outq.c_cf;
SET(tp->t_state, TS_BUSY);
diff --git a/sys/dev/sbus/spif.c b/sys/dev/sbus/spif.c
index d206e1bbfe9..738f5dfb881 100644
--- a/sys/dev/sbus/spif.c
+++ b/sys/dev/sbus/spif.c
@@ -1,4 +1,4 @@
-/* $NetBSD: spif.c,v 1.13 2007/11/07 15:56:21 ad Exp $ */
+/* $NetBSD: spif.c,v 1.14 2007/11/19 18:51:50 ad Exp $ */
/* $OpenBSD: spif.c,v 1.12 2003/10/03 16:44:51 miod Exp $ */
/*
@@ -41,7 +41,7 @@
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: spif.c,v 1.13 2007/11/07 15:56:21 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: spif.c,v 1.14 2007/11/19 18:51:50 ad Exp $");
#include "spif.h"
#if NSPIF > 0
@@ -739,14 +739,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);
- }
- if (tp->t_outq.c_cc) {
+ if (ttypull(tp)) {
sp->sp_txc = ndqb(&tp->t_outq, 0);
sp->sp_txp = tp->t_outq.c_cf;
SET(tp->t_state, TS_BUSY);
diff --git a/sys/dev/usb/ucom.c b/sys/dev/usb/ucom.c
index 235e90d3169..d248f8521aa 100644
--- a/sys/dev/usb/ucom.c
+++ b/sys/dev/usb/ucom.c
@@ -1,4 +1,4 @@
-/* $NetBSD: ucom.c,v 1.72 2007/11/12 14:20:41 ad Exp $ */
+/* $NetBSD: ucom.c,v 1.73 2007/11/19 18:51:50 ad Exp $ */
/*
* Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
@@ -41,7 +41,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ucom.c,v 1.72 2007/11/12 14:20:41 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ucom.c,v 1.73 2007/11/19 18:51:50 ad Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -913,15 +913,8 @@ 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;
- }
+ if (!ttypull(tp))
+ goto out;
/* Grab the first contiguous region of buffer space. */
data = tp->t_outq.c_cf;
diff --git a/sys/dev/usb/ucycom.c b/sys/dev/usb/ucycom.c
index cf50e235de6..9b8b3428c53 100644
--- a/sys/dev/usb/ucycom.c
+++ b/sys/dev/usb/ucycom.c
@@ -1,4 +1,4 @@
-/* $NetBSD: ucycom.c,v 1.18 2007/11/10 18:29:37 ad Exp $ */
+/* $NetBSD: ucycom.c,v 1.19 2007/11/19 18:51:51 ad Exp $ */
/*
* Copyright (c) 2005 The NetBSD Foundation, Inc.
@@ -45,7 +45,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: ucycom.c,v 1.18 2007/11/10 18:29:37 ad Exp $");
+__RCSID("$NetBSD: ucycom.c,v 1.19 2007/11/19 18:51:51 ad Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -472,15 +472,8 @@ ucycomstart(struct tty *tp)
goto out;
#endif
- 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;
- }
+ if (ttypull(tp) == 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 65621e115eb..3e46ba7af52 100644
--- a/sys/dev/wscons/wsdisplay.c
+++ b/sys/dev/wscons/wsdisplay.c
@@ -1,4 +1,4 @@
-/* $NetBSD: wsdisplay.c,v 1.111 2007/10/18 21:08:18 joerg Exp $ */
+/* $NetBSD: wsdisplay.c,v 1.112 2007/11/19 18:51:51 ad Exp $ */
/*
* Copyright (c) 1996, 1997 Christopher G. Demetriou. All rights reserved.
@@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: wsdisplay.c,v 1.111 2007/10/18 21:08:18 joerg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: wsdisplay.c,v 1.112 2007/11/19 18:51:51 ad Exp $");
#include "opt_wsdisplay_compat.h"
#include "opt_wsmsgattrs.h"
@@ -1471,17 +1471,10 @@ wsdisplaystart(struct tty *tp)
s = spltty();
tp->t_state &= ~TS_BUSY;
/* Come back if there's more to do */
- if (tp->t_outq.c_cc) {
+ if (ttypull(tp)) {
tp->t_state |= TS_TIMEOUT;
callout_schedule(&tp->t_rstrt_ch, (hz > 128) ? (hz / 128) : 1);
}
- 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);
- }
splx(s);
}