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

mxser: move FIFO clearing to mxser_disable_and_clear_FIFO()

This code is used on two places, make a helper for disabling and
clearing FIFOs. And demangle the too complicated 'if' by using a local
variable.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Link: https://lore.kernel.org/r/20210922075938.31390-5-jslaby@suse.cz
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Jiri Slaby and committed by
Greg Kroah-Hartman
ee7e5e66 bf1434c1

+12 -14
+12 -14
drivers/tty/mxser.c
··· 706 706 mxser_handle_cts(tty, port, status); 707 707 } 708 708 709 + static void mxser_disable_and_clear_FIFO(struct mxser_port *info) 710 + { 711 + u8 fcr = UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT; 712 + 713 + if (info->board->must_hwid) 714 + fcr |= MOXA_MUST_FCR_GDA_MODE_ENABLE; 715 + 716 + outb(fcr, info->ioaddr + UART_FCR); 717 + } 718 + 709 719 static int mxser_activate(struct tty_port *port, struct tty_struct *tty) 710 720 { 711 721 struct mxser_port *info = container_of(port, struct mxser_port, port); ··· 740 730 * Clear the FIFO buffers and disable them 741 731 * (they will be reenabled in mxser_change_speed()) 742 732 */ 743 - if (info->board->must_hwid) 744 - outb((UART_FCR_CLEAR_RCVR | 745 - UART_FCR_CLEAR_XMIT | 746 - MOXA_MUST_FCR_GDA_MODE_ENABLE), info->ioaddr + UART_FCR); 747 - else 748 - outb((UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT), 749 - info->ioaddr + UART_FCR); 733 + mxser_disable_and_clear_FIFO(info); 750 734 751 735 /* 752 736 * At this point there's no way the LSR could still be 0xFF; ··· 828 824 outb(0x00, info->ioaddr + UART_IER); 829 825 830 826 /* clear Rx/Tx FIFO's */ 831 - if (info->board->must_hwid) 832 - outb(UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT | 833 - MOXA_MUST_FCR_GDA_MODE_ENABLE, 834 - info->ioaddr + UART_FCR); 835 - else 836 - outb(UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT, 837 - info->ioaddr + UART_FCR); 827 + mxser_disable_and_clear_FIFO(info); 838 828 839 829 /* read data port to reset things */ 840 830 (void) inb(info->ioaddr + UART_RX);