Commit 2d68655d authored by Peter Hurley's avatar Peter Hurley Committed by Greg Kroah-Hartman
Browse files

tty: Replace ASYNC_CHECK_CD and update atomically



Replace ASYNC_CHECK_CD bit in the tty_port::flags field with
TTY_PORT_CHECK_CD bit in the tty_port::iflags field. Introduce helpers
tty_port_set_check_carrier() and tty_port_check_carrier() to abstract
the atomic bit ops.

Signed-off-by: default avatarPeter Hurley <peter@hurleysoftware.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 807c8d81
Loading
Loading
Loading
Loading
+2 −6
Original line number Diff line number Diff line
@@ -1101,7 +1101,7 @@ static void dcd_change(MGSLPC_INFO *info, struct tty_struct *tty)
	wake_up_interruptible(&info->status_event_wait_q);
	wake_up_interruptible(&info->event_wait_q);

	if (info->port.flags & ASYNC_CHECK_CD) {
	if (tty_port_check_carrier(&info->port)) {
		if (debug_level >= DEBUG_LEVEL_ISR)
			printk("%s CD now %s...", info->device_name,
			       (info->serial_signals & SerialSignal_DCD) ? "on" : "off");
@@ -1467,11 +1467,7 @@ static void mgslpc_change_params(MGSLPC_INFO *info, struct tty_struct *tty)
	info->timeout += HZ/50;		/* Add .02 seconds of slop */

	tty_port_set_cts_flow(&info->port, cflag & CRTSCTS);

	if (cflag & CLOCAL)
		info->port.flags &= ~ASYNC_CHECK_CD;
	else
		info->port.flags |= ASYNC_CHECK_CD;
	tty_port_set_check_carrier(&info->port, ~cflag & CLOCAL);

	/* process tty input control flags */

+2 −6
Original line number Diff line number Diff line
@@ -1043,11 +1043,7 @@ isdn_tty_change_speed(modem_info *info)
	if (!(cflag & PARODD))
		cval |= UART_LCR_EPAR;

	if (cflag & CLOCAL)
		port->flags &= ~ASYNC_CHECK_CD;
	else {
		port->flags |= ASYNC_CHECK_CD;
	}
	tty_port_set_check_carrier(port, ~cflag & CLOCAL);
}

static int
@@ -2526,7 +2522,7 @@ isdn_tty_modem_result(int code, modem_info *info)
		if (info->closing || (!info->port.tty))
			return;

		if (info->port.flags & ASYNC_CHECK_CD)
		if (tty_port_check_carrier(&info->port))
			tty_hangup(info->port.tty);
	}
}
+3 −6
Original line number Diff line number Diff line
@@ -398,7 +398,7 @@ static void check_modem_status(struct serial_state *info)
		wake_up_interruptible(&port->delta_msr_wait);
	}

	if ((port->flags & ASYNC_CHECK_CD) && (dstatus & SER_DCD)) {
	if (tty_port_check_carrier(port) && (dstatus & SER_DCD)) {
#if (defined(SERIAL_DEBUG_OPEN) || defined(SERIAL_DEBUG_INTR))
		printk("ttyS%d CD now %s...", info->line,
		       (!(status & SER_DCD)) ? "on" : "off");
@@ -730,12 +730,9 @@ static void change_speed(struct tty_struct *tty, struct serial_state *info,
	tty_port_set_cts_flow(port, cflag & CRTSCTS);
	if (cflag & CRTSCTS)
		info->IER |= UART_IER_MSI;
	if (cflag & CLOCAL)
		port->flags &= ~ASYNC_CHECK_CD;
	else {
		port->flags |= ASYNC_CHECK_CD;
	tty_port_set_check_carrier(port, ~cflag & CLOCAL);
	if (~cflag & CLOCAL)
		info->IER |= UART_IER_MSI;
	}
	/* TBD:
	 * Does clearing IER_MSI imply that we should disable the VBL interrupt ?
	 */
+4 −10
Original line number Diff line number Diff line
@@ -714,7 +714,7 @@ static void cyy_chip_modem(struct cyclades_card *cinfo, int chip,
		wake_up_interruptible(&info->port.delta_msr_wait);
	}

	if ((mdm_change & CyDCD) && (info->port.flags & ASYNC_CHECK_CD)) {
	if ((mdm_change & CyDCD) && tty_port_check_carrier(&info->port)) {
		if (mdm_status & CyDCD)
			wake_up_interruptible(&info->port.open_wait);
		else
@@ -1119,7 +1119,7 @@ static void cyz_handle_cmd(struct cyclades_card *cinfo)
		case C_CM_MDCD:
			info->icount.dcd++;
			delta_count++;
			if (info->port.flags & ASYNC_CHECK_CD) {
			if (tty_port_check_carrier(&info->port)) {
				u32 dcd = fw_ver > 241 ? param :
					readl(&info->u.cyz.ch_ctrl->rs_status);
				if (dcd & C_RS_DCD)
@@ -2088,10 +2088,7 @@ static void cy_set_line_char(struct cyclades_port *info, struct tty_struct *tty)
			info->cor2 |= CyCtsAE;
		else
			info->cor2 &= ~CyCtsAE;
		if (cflag & CLOCAL)
			info->port.flags &= ~ASYNC_CHECK_CD;
		else
			info->port.flags |= ASYNC_CHECK_CD;
		tty_port_set_check_carrier(&info->port, ~cflag & CLOCAL);

	 /***********************************************
	    The hardware option, CyRtsAO, presents RTS when
@@ -2250,10 +2247,7 @@ static void cy_set_line_char(struct cyclades_port *info, struct tty_struct *tty)
		}

		/* CD sensitivity */
		if (cflag & CLOCAL)
			info->port.flags &= ~ASYNC_CHECK_CD;
		else
			info->port.flags |= ASYNC_CHECK_CD;
		tty_port_set_check_carrier(&info->port, ~cflag & CLOCAL);

		if (baud == 0) {	/* baud rate is zero, turn off line */
			cy_writel(&ch_ctrl->rs_control,
+2 −5
Original line number Diff line number Diff line
@@ -577,7 +577,7 @@ static irqreturn_t isicom_interrupt(int irq, void *dev_id)
		header = inw(base);
		switch (header & 0xff) {
		case 0:	/* Change in EIA signals */
			if (port->port.flags & ASYNC_CHECK_CD) {
			if (tty_port_check_carrier(&port->port)) {
				if (port->status & ISI_DCD) {
					if (!(header & ISI_DCD)) {
					/* Carrier has been lost  */
@@ -758,10 +758,7 @@ static void isicom_config_port(struct tty_struct *tty)
		outw(channel_setup, base);
		InterruptTheCard(base);
	}
	if (C_CLOCAL(tty))
		port->port.flags &= ~ASYNC_CHECK_CD;
	else
		port->port.flags |= ASYNC_CHECK_CD;
	tty_port_set_check_carrier(&port->port, !C_CLOCAL(tty));

	/* flow control settings ...*/
	flow_ctrl = 0;
Loading