Re: [PATCH v3] serial: uartps: Add TACTIVE bit in cdns_uart_tx_empty function

From: Maarten Brock
Date: Sat Feb 01 2020 - 06:59:58 EST


On 2020-01-31 12:04, Shubhrajyoti Datta wrote:
drivers/tty/serial/xilinx_uartps.c | 22 +++++-----------------
1 file changed, 5 insertions(+), 17 deletions(-)

diff --git a/drivers/tty/serial/xilinx_uartps.c
b/drivers/tty/serial/xilinx_uartps.c
index ed2f325..ebd0a74 100644
--- a/drivers/tty/serial/xilinx_uartps.c
+++ b/drivers/tty/serial/xilinx_uartps.c
@@ -656,8 +655,9 @@ static unsigned int cdns_uart_tx_empty(struct
uart_port *port)
{
unsigned int status;

- status = readl(port->membase + CDNS_UART_SR) &
- CDNS_UART_SR_TXEMPTY;
+ status = ((readl(port->membase + CDNS_UART_SR) &
+ (CDNS_UART_SR_TXEMPTY |
+ CDNS_UART_SR_TACTIVE)) == CDNS_UART_SR_TXEMPTY);
return status ? TIOCSER_TEMT : 0;
}

These lines look pretty incomprehensible.
How about rewriting it like this?

status = readl(port->membase + CDNS_UART_SR) &
(CDNS_UART_SR_TXEMPTY | CDNS_UART_SR_TACTIVE);
return (status == CDNS_UART_SR_TXEMPTY) ? TIOCSER_TEMT : 0;

Maarten