Hi All,
Here the first of a few small patches for drivers/serial/8250.c
This patch makes the testing for an empty device more robust. Some chips
hold
the UART_TEMT bit sometime _after_ data has been written in uart_thr.
Now ioctl( ,TIOCSERGETLSR, ) returns the right status.
--- drivers/serial/8250.c.orig 2007-06-11 20:37:06.000000000 +0200
+++ drivers/serial/8250.c 2007-06-19 14:38:19.000000000 +0200
@@ -108,6 +108,7 @@ static const struct old_serial_port old_
};
#define UART_NR CONFIG_SERIAL_8250_NR_UARTS
+#define BOTH_EMPTY (UART_LSR_TEMT | UART_LSR_THRE)
#ifdef CONFIG_SERIAL_8250_RSA
@@ -1160,7 +1161,7 @@ static void serial8250_start_tx(struct u
unsigned char lsr, iir;
lsr = serial_in(up, UART_LSR);
iir = serial_in(up, UART_IIR);
- if (lsr & UART_LSR_TEMT && iir & UART_IIR_NO_INT)
+ if (((lsr & BOTH_EMPTY) == BOTH_EMPTY) && iir & UART_IIR_NO_INT)
transmit_chars(up);
}
}
@@ -1539,7 +1540,7 @@ static unsigned int serial8250_tx_empty(
unsigned int ret;
spin_lock_irqsave(&up->port.lock, flags);
- ret = serial_in(up, UART_LSR) & UART_LSR_TEMT ? TIOCSER_TEMT : 0;
+ ret = ((serial_in(up, UART_LSR) & BOTH_EMPTY) == BOTH_EMPTY) ? TIOCSER_TEMT : 0;
spin_unlock_irqrestore(&up->port.lock, flags);
return ret;
@@ -1600,7 +1601,6 @@ static void serial8250_break_ctl(struct
spin_unlock_irqrestore(&up->port.lock, flags);
}
-#define BOTH_EMPTY (UART_LSR_TEMT | UART_LSR_THRE)
/*
* Wait for transmitter & holding register to empty
@@ -1781,7 +1781,7 @@ static int serial8250_startup(struct uar
iir = serial_in(up, UART_IIR);
serial_outp(up, UART_IER, 0);
- if (lsr & UART_LSR_TEMT && iir & UART_IIR_NO_INT) {
+ if (((lsr & BOTH_EMPTY) == BOTH_EMPTY) && iir & UART_IIR_NO_INT) {
if (!(up->bugs & UART_BUG_TXEN)) {
up->bugs |= UART_BUG_TXEN;
pr_debug("ttyS%d - enabling bad tx status workarounds\n",
regards
Kees
-
To unsubscribe from this list: send the line "unsubscribe linux-serial" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html