Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Jiri Slaby and committed by
Greg Kroah-Hartman
d249e662 215fa41c

+13 -14
+13 -14
drivers/tty/mxser.c
··· 249 249 unsigned char x_char; /* xon/xoff character */ 250 250 u8 IER; /* Interrupt Enable Register */ 251 251 u8 MCR; /* Modem control register */ 252 + u8 FCR; /* FIFO control register */ 252 253 253 254 bool ldisc_stop_rx; 254 255 ··· 563 562 static void mxser_change_speed(struct tty_struct *tty, struct ktermios *old_termios) 564 563 { 565 564 struct mxser_port *info = tty->driver_data; 566 - unsigned cflag, cval, fcr; 565 + unsigned cflag, cval; 567 566 568 567 cflag = tty->termios.c_cflag; 569 568 ··· 601 600 if (cflag & CMSPAR) 602 601 cval |= UART_LCR_SPAR; 603 602 604 - fcr = 0; 603 + info->FCR = 0; 605 604 if (info->board->must_hwid) { 606 - fcr |= UART_FCR_ENABLE_FIFO | 605 + info->FCR |= UART_FCR_ENABLE_FIFO | 607 606 MOXA_MUST_FCR_GDA_MODE_ENABLE; 608 607 mxser_set_must_fifo_value(info); 609 608 } else if (info->type != PORT_8250 && info->type != PORT_16450) { 610 - fcr |= UART_FCR_ENABLE_FIFO; 609 + info->FCR |= UART_FCR_ENABLE_FIFO; 611 610 switch (info->rx_high_water) { 612 611 case 1: 613 - fcr |= UART_FCR_TRIGGER_1; 612 + info->FCR |= UART_FCR_TRIGGER_1; 614 613 break; 615 614 case 4: 616 - fcr |= UART_FCR_TRIGGER_4; 615 + info->FCR |= UART_FCR_TRIGGER_4; 617 616 break; 618 617 case 8: 619 - fcr |= UART_FCR_TRIGGER_8; 618 + info->FCR |= UART_FCR_TRIGGER_8; 620 619 break; 621 620 default: 622 - fcr |= UART_FCR_TRIGGER_14; 621 + info->FCR |= UART_FCR_TRIGGER_14; 623 622 break; 624 623 } 625 624 } ··· 680 679 } 681 680 682 681 683 - outb(fcr, info->ioaddr + UART_FCR); /* set fcr */ 682 + outb(info->FCR, info->ioaddr + UART_FCR); 684 683 outb(cval, info->ioaddr + UART_LCR); 685 684 } 686 685 ··· 866 865 spin_lock_irqsave(&info->slock, flags); 867 866 info->xmit_cnt = info->xmit_head = info->xmit_tail = 0; 868 867 869 - outb(UART_FCR_ENABLE_FIFO | UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT, 868 + outb(info->FCR | UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT, 870 869 info->ioaddr + UART_FCR); 871 870 872 871 spin_unlock_irqrestore(&info->slock, flags); ··· 1573 1572 1574 1573 ch = inb(port->ioaddr + UART_RX); 1575 1574 if (hwid && (status & UART_LSR_OE)) 1576 - outb(UART_FCR_ENABLE_FIFO | UART_FCR_CLEAR_RCVR | 1577 - MOXA_MUST_FCR_GDA_MODE_ENABLE, 1575 + outb(port->FCR | UART_FCR_CLEAR_RCVR, 1578 1576 port->ioaddr + UART_FCR); 1579 1577 status &= port->read_status_mask; 1580 1578 if (status & port->ignore_status_mask) { ··· 1685 1685 tty = tty_port_tty_get(&port->port); 1686 1686 if (!tty || port->closing || !tty_port_initialized(&port->port)) { 1687 1687 status = inb(port->ioaddr + UART_LSR); 1688 - outb(MOXA_MUST_FCR_GDA_MODE_ENABLE | UART_FCR_ENABLE_FIFO | 1689 - UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT, 1688 + outb(port->FCR | UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT, 1690 1689 port->ioaddr + UART_FCR); 1691 1690 inb(port->ioaddr + UART_MSR); 1692 1691