sys/dev/usbmisc/ucom/ucom.c
static int
ucomctl(struct ucom_softc *sc, int bits, int how)
{
	int	mcr;
	int	msr;
	int	onoff;

	ASSERT_LWKT_TOKEN_HELD(&tty_token);
	DPRINTF(("ucomctl: bits = 0x%x, how = %d\n", bits, how));

	if (how == DMGET) {
		SET(bits, TIOCM_LE);		/* always set TIOCM_LE bit */
		DPRINTF(("ucomctl: DMGET: LE"));

		mcr = sc->sc_mcr;
		if (ISSET(mcr, UMCR_DTR)) {
			SET(bits, TIOCM_DTR);
			DPRINTF((" DTR"));
		}
		if (ISSET(mcr, UMCR_RTS)) {
			SET(bits, TIOCM_RTS);
			DPRINTF((" RTS"));
		}

		msr = sc->sc_msr;
		if (ISSET(msr, UMSR_CTS)) {
			SET(bits, TIOCM_CTS);
			DPRINTF((" CTS"));
		}
		if (ISSET(msr, UMSR_DCD)) {
			SET(bits, TIOCM_CD);
			DPRINTF((" CD"));
		}
		if (ISSET(msr, UMSR_DSR)) {
			SET(bits, TIOCM_DSR);
			DPRINTF((" DSR"));
		}
		if (ISSET(msr, UMSR_RI)) {
			SET(bits, TIOCM_RI);
			DPRINTF((" RI"));
		}

		DPRINTF(("\n"));

		return (bits);
	}

	mcr = 0;
	if (ISSET(bits, TIOCM_DTR))
		SET(mcr, UMCR_DTR);
	if (ISSET(bits, TIOCM_RTS))
		SET(mcr, UMCR_RTS);

	switch (how) {
	case DMSET:
		sc->sc_mcr = mcr;
		break;
	case DMBIS:
		sc->sc_mcr |= mcr;
		break;
	case DMBIC:
		sc->sc_mcr &= ~mcr;
		break;
	}

	onoff = ISSET(sc->sc_mcr, UMCR_DTR) ? 1 : 0;
	ucom_dtr(sc, onoff);

	onoff = ISSET(sc->sc_mcr, UMCR_RTS) ? 1 : 0;
	ucom_rts(sc, onoff);

	return (0);
}
/*
 * NOTE: Must be called with tty_token held.
 */
Must be called with tty_token held.
Must be called with tty_token held .
static int
ucomctl(struct ucom_softc *sc, int bits, int how)
{
	int	mcr;
	int	msr;
	int	onoff;
	ASSERT_LWKT_TOKEN_HELD(&tty_token);
	DPRINTF(("ucomctl: bits = 0x%x, how = %d\n", bits, how));
	if (how == DMGET) {
		SET(bits, TIOCM_LE);		
		DPRINTF(("ucomctl: DMGET: LE"));
		mcr = sc->sc_mcr;
		if (ISSET(mcr, UMCR_DTR)) {
			SET(bits, TIOCM_DTR);
			DPRINTF((" DTR"));
		}
		if (ISSET(mcr, UMCR_RTS)) {
			SET(bits, TIOCM_RTS);
			DPRINTF((" RTS"));
		}
		msr = sc->sc_msr;
		if (ISSET(msr, UMSR_CTS)) {
			SET(bits, TIOCM_CTS);
			DPRINTF((" CTS"));
		}
		if (ISSET(msr, UMSR_DCD)) {
			SET(bits, TIOCM_CD);
			DPRINTF((" CD"));
		}
		if (ISSET(msr, UMSR_DSR)) {
			SET(bits, TIOCM_DSR);
			DPRINTF((" DSR"));
		}
		if (ISSET(msr, UMSR_RI)) {
			SET(bits, TIOCM_RI);
			DPRINTF((" RI"));
		}
		DPRINTF(("\n"));
		return (bits);
	}
	mcr = 0;
	if (ISSET(bits, TIOCM_DTR))
		SET(mcr, UMCR_DTR);
	if (ISSET(bits, TIOCM_RTS))
		SET(mcr, UMCR_RTS);
	switch (how) {
	case DMSET:
		sc->sc_mcr = mcr;
		break;
	case DMBIS:
		sc->sc_mcr |= mcr;
		break;
	case DMBIC:
		sc->sc_mcr &= ~mcr;
		break;
	}
	onoff = ISSET(sc->sc_mcr, UMCR_DTR) ? 1 : 0;
	ucom_dtr(sc, onoff);
	onoff = ISSET(sc->sc_mcr, UMCR_RTS) ? 1 : 0;
	ucom_rts(sc, onoff);
	return (0);
}
static int ucomctl ( struct ucom_softc * sc , int bits , int how ) { int mcr ; int msr ; int onoff ; ASSERT_LWKT_TOKEN_HELD ( & tty_token ) ; DPRINTF ( ( " \n " , bits , how ) ) ; if ( how == DMGET ) { SET ( bits , TIOCM_LE ) ; DPRINTF ( ( " " ) ) ; mcr = sc -> sc_mcr ; if ( ISSET ( mcr , UMCR_DTR ) ) { SET ( bits , TIOCM_DTR ) ; DPRINTF ( ( " " ) ) ; } if ( ISSET ( mcr , UMCR_RTS ) ) { SET ( bits , TIOCM_RTS ) ; DPRINTF ( ( " " ) ) ; } msr = sc -> sc_msr ; if ( ISSET ( msr , UMSR_CTS ) ) { SET ( bits , TIOCM_CTS ) ; DPRINTF ( ( " " ) ) ; } if ( ISSET ( msr , UMSR_DCD ) ) { SET ( bits , TIOCM_CD ) ; DPRINTF ( ( " " ) ) ; } if ( ISSET ( msr , UMSR_DSR ) ) { SET ( bits , TIOCM_DSR ) ; DPRINTF ( ( " " ) ) ; } if ( ISSET ( msr , UMSR_RI ) ) { SET ( bits , TIOCM_RI ) ; DPRINTF ( ( " " ) ) ; } DPRINTF ( ( " \n " ) ) ; return ( bits ) ; } mcr = 0 ; if ( ISSET ( bits , TIOCM_DTR ) ) SET ( mcr , UMCR_DTR ) ; if ( ISSET ( bits , TIOCM_RTS ) ) SET ( mcr , UMCR_RTS ) ; switch ( how ) { case DMSET : sc -> sc_mcr = mcr ; break ; case DMBIS : sc -> sc_mcr |= mcr ; break ; case DMBIC : sc -> sc_mcr &= ~ mcr ; break ; } onoff = ISSET ( sc -> sc_mcr , UMCR_DTR ) ? 1 : 0 ; ucom_dtr ( sc , onoff ) ; onoff = ISSET ( sc -> sc_mcr , UMCR_RTS ) ? 1 : 0 ; ucom_rts ( sc , onoff ) ; return ( 0 ) ; }
NOTE: Must be called with tty_token held.
NOTE : Must be called with tty_token held .
/* always set TIOCM_LE bit */