diff options
author | Jiri Slaby <jslaby@suse.cz> | 2021-09-22 09:59:38 +0200 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2021-10-05 14:08:09 +0200 |
commit | d249e662c3e4a9d2caebf74487cf283cb6df2f77 (patch) | |
tree | 9e1d630daacba7315372761df1bb8aad84e5c51a /drivers/tty | |
parent | mxser: don't read from UART_FCR (diff) | |
download | linux-d249e662c3e4a9d2caebf74487cf283cb6df2f77.tar.xz linux-d249e662c3e4a9d2caebf74487cf283cb6df2f77.zip |
mxser: store FCR state in mxser_port::FCR
We force the FCR contents on many places in the code instead of writing
what was actually set in mxser_change_speed() (by ->activate() or
->set_serial_info()).
So introduce mxser_port::FCR to hold the proper contents and bitwise-OR
the value to what needs to be set on all those locations. That is,
clearing RX and/or TX FIFOs. Those flags are self-clearing, so no need
to set them to mxser_port::FCR.
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Link: https://lore.kernel.org/r/20210922075938.31390-7-jslaby@suse.cz
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/tty')
-rw-r--r-- | drivers/tty/mxser.c | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/drivers/tty/mxser.c b/drivers/tty/mxser.c index 4ce21cdb1ea5..93a95a135a71 100644 --- a/drivers/tty/mxser.c +++ b/drivers/tty/mxser.c @@ -249,6 +249,7 @@ struct mxser_port { unsigned char x_char; /* xon/xoff character */ u8 IER; /* Interrupt Enable Register */ u8 MCR; /* Modem control register */ + u8 FCR; /* FIFO control register */ bool ldisc_stop_rx; @@ -562,7 +563,7 @@ static void mxser_handle_cts(struct tty_struct *tty, struct mxser_port *info, static void mxser_change_speed(struct tty_struct *tty, struct ktermios *old_termios) { struct mxser_port *info = tty->driver_data; - unsigned cflag, cval, fcr; + unsigned cflag, cval; cflag = tty->termios.c_cflag; @@ -600,25 +601,25 @@ static void mxser_change_speed(struct tty_struct *tty, struct ktermios *old_term if (cflag & CMSPAR) cval |= UART_LCR_SPAR; - fcr = 0; + info->FCR = 0; if (info->board->must_hwid) { - fcr |= UART_FCR_ENABLE_FIFO | + info->FCR |= UART_FCR_ENABLE_FIFO | MOXA_MUST_FCR_GDA_MODE_ENABLE; mxser_set_must_fifo_value(info); } else if (info->type != PORT_8250 && info->type != PORT_16450) { - fcr |= UART_FCR_ENABLE_FIFO; + info->FCR |= UART_FCR_ENABLE_FIFO; switch (info->rx_high_water) { case 1: - fcr |= UART_FCR_TRIGGER_1; + info->FCR |= UART_FCR_TRIGGER_1; break; case 4: - fcr |= UART_FCR_TRIGGER_4; + info->FCR |= UART_FCR_TRIGGER_4; break; case 8: - fcr |= UART_FCR_TRIGGER_8; + info->FCR |= UART_FCR_TRIGGER_8; break; default: - fcr |= UART_FCR_TRIGGER_14; + info->FCR |= UART_FCR_TRIGGER_14; break; } } @@ -679,7 +680,7 @@ static void mxser_change_speed(struct tty_struct *tty, struct ktermios *old_term } - outb(fcr, info->ioaddr + UART_FCR); /* set fcr */ + outb(info->FCR, info->ioaddr + UART_FCR); outb(cval, info->ioaddr + UART_LCR); } @@ -865,7 +866,7 @@ static void mxser_flush_buffer(struct tty_struct *tty) spin_lock_irqsave(&info->slock, flags); info->xmit_cnt = info->xmit_head = info->xmit_tail = 0; - outb(UART_FCR_ENABLE_FIFO | UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT, + outb(info->FCR | UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT, info->ioaddr + UART_FCR); spin_unlock_irqrestore(&info->slock, flags); @@ -1572,8 +1573,7 @@ static u8 mxser_receive_chars_old(struct tty_struct *tty, ch = inb(port->ioaddr + UART_RX); if (hwid && (status & UART_LSR_OE)) - outb(UART_FCR_ENABLE_FIFO | UART_FCR_CLEAR_RCVR | - MOXA_MUST_FCR_GDA_MODE_ENABLE, + outb(port->FCR | UART_FCR_CLEAR_RCVR, port->ioaddr + UART_FCR); status &= port->read_status_mask; if (status & port->ignore_status_mask) { @@ -1685,8 +1685,7 @@ static bool mxser_port_isr(struct mxser_port *port) tty = tty_port_tty_get(&port->port); if (!tty || port->closing || !tty_port_initialized(&port->port)) { status = inb(port->ioaddr + UART_LSR); - outb(MOXA_MUST_FCR_GDA_MODE_ENABLE | UART_FCR_ENABLE_FIFO | - UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT, + outb(port->FCR | UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT, port->ioaddr + UART_FCR); inb(port->ioaddr + UART_MSR); |