Skip to content

Commit ff446fb

Browse files
Jiri Slaby (SUSE)gregkh
authored andcommitted
serial: 8250: extract serial8250_iir_txen_test()
After commit 7951586 ("serial: 8250: extract serial8250_initialize()"), split serial8250_initialize() even more -- the TX enable test part of this code can be separated into serial8250_iir_txen_test(). Signed-off-by: "Jiri Slaby (SUSE)" <[email protected]> Suggested-by: Ilpo Järvinen <[email protected]> Reviewed-by: Ilpo Järvinen <[email protected]> Reviewed-by: Andy Shevchenko <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 7bdf59c commit ff446fb

File tree

1 file changed

+28
-21
lines changed

1 file changed

+28
-21
lines changed

drivers/tty/serial/8250/8250_port.c

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2230,43 +2230,50 @@ static void serial8250_init_mctrl(struct uart_port *port)
22302230
serial8250_set_mctrl(port, port->mctrl);
22312231
}
22322232

2233-
static void serial8250_initialize(struct uart_port *port)
2233+
static void serial8250_iir_txen_test(struct uart_port *port)
22342234
{
22352235
struct uart_8250_port *up = up_to_u8250p(port);
2236-
unsigned long flags;
22372236
bool lsr_TEMT, iir_NOINT;
22382237

2239-
serial_port_out(port, UART_LCR, UART_LCR_WLEN8);
2238+
if (port->quirks & UPQ_NO_TXEN_TEST)
2239+
return;
22402240

2241-
uart_port_lock_irqsave(port, &flags);
2242-
serial8250_init_mctrl(port);
2241+
/* Do a quick test to see if we receive an interrupt when we enable the TX irq. */
2242+
serial_port_out(port, UART_IER, UART_IER_THRI);
2243+
lsr_TEMT = serial_port_in(port, UART_LSR) & UART_LSR_TEMT;
2244+
iir_NOINT = serial_port_in(port, UART_IIR) & UART_IIR_NO_INT;
2245+
serial_port_out(port, UART_IER, 0);
22432246

22442247
/*
22452248
* Serial over Lan (SoL) hack:
22462249
* Intel 8257x Gigabit ethernet chips have a 16550 emulation, to be used for Serial Over
22472250
* Lan. Those chips take a longer time than a normal serial device to signalize that a
22482251
* transmission data was queued. Due to that, the above test generally fails. One solution
22492252
* would be to delay the reading of iir. However, this is not reliable, since the timeout is
2250-
* variable. So, let's just don't test if we receive TX irq. This way, we'll never enable
2251-
* UART_BUG_TXEN.
2253+
* variable. So, in case of UPQ_NO_TXEN_TEST, let's just don't test if we receive TX irq.
2254+
* This way, we'll never enable UART_BUG_TXEN.
22522255
*/
2253-
if (!(port->quirks & UPQ_NO_TXEN_TEST)) {
2254-
/* Do a quick test to see if we receive an interrupt when we enable the TX irq. */
2255-
serial_port_out(port, UART_IER, UART_IER_THRI);
2256-
lsr_TEMT = serial_port_in(port, UART_LSR) & UART_LSR_TEMT;
2257-
iir_NOINT = serial_port_in(port, UART_IIR) & UART_IIR_NO_INT;
2258-
serial_port_out(port, UART_IER, 0);
2259-
2260-
if (lsr_TEMT && iir_NOINT) {
2261-
if (!(up->bugs & UART_BUG_TXEN)) {
2262-
up->bugs |= UART_BUG_TXEN;
2263-
dev_dbg(port->dev, "enabling bad tx status workarounds\n");
2264-
}
2265-
} else {
2266-
up->bugs &= ~UART_BUG_TXEN;
2256+
if (lsr_TEMT && iir_NOINT) {
2257+
if (!(up->bugs & UART_BUG_TXEN)) {
2258+
up->bugs |= UART_BUG_TXEN;
2259+
dev_dbg(port->dev, "enabling bad tx status workarounds\n");
22672260
}
2261+
return;
22682262
}
22692263

2264+
/* FIXME: why is this needed? */
2265+
up->bugs &= ~UART_BUG_TXEN;
2266+
}
2267+
2268+
static void serial8250_initialize(struct uart_port *port)
2269+
{
2270+
unsigned long flags;
2271+
2272+
serial_port_out(port, UART_LCR, UART_LCR_WLEN8);
2273+
2274+
uart_port_lock_irqsave(port, &flags);
2275+
serial8250_init_mctrl(port);
2276+
serial8250_iir_txen_test(port);
22702277
uart_port_unlock_irqrestore(port, flags);
22712278
}
22722279

0 commit comments

Comments
 (0)