From 85dbe7ca610ea8b756d4a3368612571b4867502a Mon Sep 17 00:00:00 2001 From: Theo de Raadt Date: Mon, 27 Mar 2006 06:14:53 +0000 Subject: in detach, mark device with COM_SW_DEAD, so that close() will not go tapping additional registes. allows it to work on macppc, where doing such a tap after unplug is very bad. drahn helped fkr@bytemine.de ok miod and drahn --- sys/dev/ic/com.c | 7 ++++++- sys/dev/ic/comvar.h | 3 ++- 2 files changed, 8 insertions(+), 2 deletions(-) (limited to 'sys/dev/ic') diff --git a/sys/dev/ic/com.c b/sys/dev/ic/com.c index 2314b4205ac..cd245649229 100644 --- a/sys/dev/ic/com.c +++ b/sys/dev/ic/com.c @@ -1,4 +1,4 @@ -/* $OpenBSD: com.c,v 1.109 2006/01/01 11:59:40 miod Exp $ */ +/* $OpenBSD: com.c,v 1.110 2006/03/27 06:14:52 deraadt Exp $ */ /* $NetBSD: com.c,v 1.82.4.1 1996/06/02 09:08:00 mrg Exp $ */ /* @@ -207,6 +207,8 @@ com_detach(self, flags) struct com_softc *sc = (struct com_softc *)self; int maj, mn; + sc->sc_swflags |= COM_SW_DEAD; + /* locate the major number */ for (maj = 0; maj < nchrdev; maj++) if (cdevsw[maj].d_open == comopen) @@ -501,6 +503,9 @@ comclose(dev, flag, mode, p) return 0; #endif + if(sc->sc_swflags & COM_SW_DEAD) + return 0; + (*linesw[tp->t_line].l_close)(tp, flag); s = spltty(); if (ISSET(tp->t_state, TS_WOPEN)) { diff --git a/sys/dev/ic/comvar.h b/sys/dev/ic/comvar.h index 3cbb457be78..7ee7cb7d7cc 100644 --- a/sys/dev/ic/comvar.h +++ b/sys/dev/ic/comvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: comvar.h,v 1.37 2005/10/24 14:22:34 fgsch Exp $ */ +/* $OpenBSD: comvar.h,v 1.38 2006/03/27 06:14:52 deraadt Exp $ */ /* $NetBSD: comvar.h,v 1.5 1996/05/05 19:50:47 christos Exp $ */ /* @@ -117,6 +117,7 @@ struct com_softc { #define COM_SW_CRTSCTS 0x04 #define COM_SW_MDMBUF 0x08 #define COM_SW_PPS 0x10 +#define COM_SW_DEAD 0x20 int sc_fifolen; u_char sc_msr, sc_mcr, sc_lcr, sc_ier; u_char sc_dtr; -- cgit v1.2.3