Commit b3696289 authored by Shubhrajyoti Datta's avatar Shubhrajyoti Datta Committed by Greg Kroah-Hartman
Browse files

tty: xilinx_uartps: Prevent writes when the controller is disabled

parent b8a6c3b3
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -1132,6 +1132,21 @@ static struct uart_driver cdns_uart_uart_driver;
 */
static void cdns_uart_console_putchar(struct uart_port *port, unsigned char ch)
{
	unsigned int ctrl_reg;
	unsigned long timeout;

	timeout = jiffies + msecs_to_jiffies(1000);
	while (1) {
		ctrl_reg = readl(port->membase + CDNS_UART_CR);
		if (!(ctrl_reg & CDNS_UART_CR_TX_DIS))
			break;
		if (time_after(jiffies, timeout)) {
			dev_warn(port->dev,
				 "timeout waiting for Enable\n");
			return;
		}
		cpu_relax();
	}
	while (readl(port->membase + CDNS_UART_SR) & CDNS_UART_SR_TXFULL)
		cpu_relax();
	writel(ch, port->membase + CDNS_UART_FIFO);