Index: src/sys/arch/i386/isa/pccom.c
===================================================================
RCS file: /cvs/src/sys/arch/i386/isa/pccom.c,v
retrieving revision 1.29
retrieving revision 1.30
diff -c -r1.29 -r1.30
*** src/sys/arch/i386/isa/pccom.c	1999/02/08 23:43:54	1.29
--- src/sys/arch/i386/isa/pccom.c	1999/05/21 16:06:13	1.30
***************
*** 1,4 ****
! /*	$OpenBSD: pccom.c,v 1.29 1999/02/08 23:43:54 rees Exp $	*/
  /*	$NetBSD: com.c,v 1.82.4.1 1996/06/02 09:08:00 mrg Exp $	*/
  
  /*
--- 1,4 ----
! /*	$OpenBSD: pccom.c,v 1.30 1999/05/21 16:06:13 rees Exp $	*/
  /*	$NetBSD: com.c,v 1.82.4.1 1996/06/02 09:08:00 mrg Exp $	*/
  
  /*
***************
*** 122,127 ****
--- 122,128 ----
  void	com_absent_notify __P((struct com_softc *sc));
  void	comstart_pending __P((void *));
  void	compwroff __P((struct com_softc *));
+ void	com_raisedtr __P((void *));
  
  #if NPCCOM_ISA
  struct cfattach pccom_isa_ca = {
***************
*** 1111,1119 ****
  			       (!ISSET(tp->t_cflag, CLOCAL) &&
  				!ISSET(tp->t_state, TS_CARR_ON))) {
  				SET(tp->t_state, TS_WOPEN);
! 				error = ttysleep(tp, &tp->t_rawq, TTIPRI | PCATCH,
! 						 ttopen, 0);
! 				if (error) {
  					CLR(tp->t_state, TS_WOPEN);
  					if (!sc->sc_cua && !ISSET(tp->t_state, TS_ISOPEN))
  						compwroff(sc);
--- 1112,1124 ----
  			       (!ISSET(tp->t_cflag, CLOCAL) &&
  				!ISSET(tp->t_state, TS_CARR_ON))) {
  				SET(tp->t_state, TS_WOPEN);
! 				error = ttysleep(tp, &tp->t_rawq, TTIPRI | PCATCH, ttopen, 0);
! 				/*
! 				 * If TS_WOPEN has been reset, that means the cua device
! 				 * has been closed.  We don't want to fail in that case,
! 				 * so just go around again.
! 				 */
! 				if (error && ISSET(tp->t_state, TS_WOPEN)) {
  					CLR(tp->t_state, TS_WOPEN);
  					if (!sc->sc_cua && !ISSET(tp->t_state, TS_ISOPEN))
  						compwroff(sc);
***************
*** 1135,1140 ****
--- 1140,1147 ----
  {
  	int unit = DEVUNIT(dev);
  	struct com_softc *sc = pccom_cd.cd_devs[unit];
+ 	bus_space_tag_t iot = sc->sc_iot;
+ 	bus_space_handle_t ioh = sc->sc_ioh;
  	struct tty *tp = sc->sc_tty;
  	int s;
  
***************
*** 1144,1151 ****
  
  	(*linesw[tp->t_line].l_close)(tp, flag);
  	s = spltty();
! 	if (!ISSET(sc->sc_hwflags, COM_HW_ABSENT|COM_HW_ABSENT_PENDING))
! 		compwroff(sc);
  	CLR(tp->t_state, TS_BUSY | TS_FLUSH);
  	sc->sc_cua = 0;
  	splx(s);
--- 1151,1167 ----
  
  	(*linesw[tp->t_line].l_close)(tp, flag);
  	s = spltty();
! 	if (!ISSET(sc->sc_hwflags, COM_HW_ABSENT|COM_HW_ABSENT_PENDING)) {
! 		if (ISSET(tp->t_state, TS_WOPEN)) {
! 			/* tty device is waiting for carrier; drop dtr then re-raise */
! 			CLR(sc->sc_mcr, MCR_DTR | MCR_RTS);
! 			bus_space_write_1(iot, ioh, com_mcr, sc->sc_mcr);
! 			timeout(com_raisedtr, sc, hz * 2);
! 		} else {
! 			/* no one else waiting; turn off the uart */
! 			compwroff(sc);
! 		}
! 	}
  	CLR(tp->t_state, TS_BUSY | TS_FLUSH);
  	sc->sc_cua = 0;
  	splx(s);
***************
*** 1181,1187 ****
  	if (ISSET(tp->t_cflag, HUPCL) &&
  	    !ISSET(sc->sc_swflags, COM_SW_SOFTCAR)) {
  		/* XXX perhaps only clear DTR */
! 		bus_space_write_1(iot, ioh, com_mcr, 0);
  	}
  
  	/*
--- 1197,1204 ----
  	if (ISSET(tp->t_cflag, HUPCL) &&
  	    !ISSET(sc->sc_swflags, COM_SW_SOFTCAR)) {
  		/* XXX perhaps only clear DTR */
! 		sc->sc_mcr = 0;
! 		bus_space_write_1(iot, ioh, com_mcr, sc->sc_mcr);
  	}
  
  	/*
***************
*** 1209,1214 ****
--- 1226,1241 ----
  		break;
  #endif
  	}
+ }
+ 
+ void
+ com_raisedtr(arg)
+ 	void *arg;
+ {
+ 	struct com_softc *sc = arg;
+ 
+ 	SET(sc->sc_mcr, MCR_DTR | MCR_RTS);
+ 	bus_space_write_1(sc->sc_iot, sc->sc_ioh, com_mcr, sc->sc_mcr);
  }
  
  int
