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>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
bf1434c1b7
commit
ee7e5e66f2
@ -706,6 +706,16 @@ static void mxser_check_modem_status(struct tty_struct *tty,
|
|||||||
mxser_handle_cts(tty, port, status);
|
mxser_handle_cts(tty, port, status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void mxser_disable_and_clear_FIFO(struct mxser_port *info)
|
||||||
|
{
|
||||||
|
u8 fcr = UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT;
|
||||||
|
|
||||||
|
if (info->board->must_hwid)
|
||||||
|
fcr |= MOXA_MUST_FCR_GDA_MODE_ENABLE;
|
||||||
|
|
||||||
|
outb(fcr, info->ioaddr + UART_FCR);
|
||||||
|
}
|
||||||
|
|
||||||
static int mxser_activate(struct tty_port *port, struct tty_struct *tty)
|
static int mxser_activate(struct tty_port *port, struct tty_struct *tty)
|
||||||
{
|
{
|
||||||
struct mxser_port *info = container_of(port, struct mxser_port, port);
|
struct mxser_port *info = container_of(port, struct mxser_port, port);
|
||||||
@ -730,13 +740,7 @@ static int mxser_activate(struct tty_port *port, struct tty_struct *tty)
|
|||||||
* Clear the FIFO buffers and disable them
|
* Clear the FIFO buffers and disable them
|
||||||
* (they will be reenabled in mxser_change_speed())
|
* (they will be reenabled in mxser_change_speed())
|
||||||
*/
|
*/
|
||||||
if (info->board->must_hwid)
|
mxser_disable_and_clear_FIFO(info);
|
||||||
outb((UART_FCR_CLEAR_RCVR |
|
|
||||||
UART_FCR_CLEAR_XMIT |
|
|
||||||
MOXA_MUST_FCR_GDA_MODE_ENABLE), info->ioaddr + UART_FCR);
|
|
||||||
else
|
|
||||||
outb((UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT),
|
|
||||||
info->ioaddr + UART_FCR);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* At this point there's no way the LSR could still be 0xFF;
|
* At this point there's no way the LSR could still be 0xFF;
|
||||||
@ -824,13 +828,7 @@ static void mxser_shutdown_port(struct tty_port *port)
|
|||||||
outb(0x00, info->ioaddr + UART_IER);
|
outb(0x00, info->ioaddr + UART_IER);
|
||||||
|
|
||||||
/* clear Rx/Tx FIFO's */
|
/* clear Rx/Tx FIFO's */
|
||||||
if (info->board->must_hwid)
|
mxser_disable_and_clear_FIFO(info);
|
||||||
outb(UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT |
|
|
||||||
MOXA_MUST_FCR_GDA_MODE_ENABLE,
|
|
||||||
info->ioaddr + UART_FCR);
|
|
||||||
else
|
|
||||||
outb(UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT,
|
|
||||||
info->ioaddr + UART_FCR);
|
|
||||||
|
|
||||||
/* read data port to reset things */
|
/* read data port to reset things */
|
||||||
(void) inb(info->ioaddr + UART_RX);
|
(void) inb(info->ioaddr + UART_RX);
|
||||||
|
Reference in New Issue
Block a user