Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0dd7a1ae authored by Russell King's avatar Russell King Committed by Russell King
Browse files

[PATCH] Serial: Check status of CTS when using flow control



Fix bugme #4712: read the CTS status and set hw_stopped if CTS
is not active when opening the port and/or enabling CRTSCTS

Thanks to Stefan Wolff for spotting this problem.

Signed-off-by: default avatarRussell King <rmk+kernel@arm.linux.org.uk>
parent c5f4644e
Loading
Loading
Loading
Loading
+17 −0
Original line number Original line Diff line number Diff line
@@ -182,6 +182,13 @@ static int uart_startup(struct uart_state *state, int init_hw)
				uart_set_mctrl(port, TIOCM_RTS | TIOCM_DTR);
				uart_set_mctrl(port, TIOCM_RTS | TIOCM_DTR);
		}
		}


		if (info->flags & UIF_CTS_FLOW) {
			spin_lock_irq(&port->lock);
			if (!(port->ops->get_mctrl(port) & TIOCM_CTS))
				info->tty->hw_stopped = 1;
			spin_unlock_irq(&port->lock);
		}

		info->flags |= UIF_INITIALIZED;
		info->flags |= UIF_INITIALIZED;


		clear_bit(TTY_IO_ERROR, &info->tty->flags);
		clear_bit(TTY_IO_ERROR, &info->tty->flags);
@@ -1134,6 +1141,16 @@ static void uart_set_termios(struct tty_struct *tty, struct termios *old_termios
		spin_unlock_irqrestore(&state->port->lock, flags);
		spin_unlock_irqrestore(&state->port->lock, flags);
	}
	}


	/* Handle turning on CRTSCTS */
	if (!(old_termios->c_cflag & CRTSCTS) && (cflag & CRTSCTS)) {
		spin_lock_irqsave(&state->port->lock, flags);
		if (!(state->port->ops->get_mctrl(state->port) & TIOCM_CTS)) {
			tty->hw_stopped = 1;
			state->port->ops->stop_tx(state->port, 0);
		}
		spin_unlock_irqrestore(&state->port->lock, flags);
	}

#if 0
#if 0
	/*
	/*
	 * No need to wake up processes in open wait, since they
	 * No need to wake up processes in open wait, since they