Message ID | 20250410004324.89383-6-abhishek@linux.ibm.com |
---|---|
State | Accepted |
Headers | show |
Series | Fixed UART handling | expand |
On 25/04/10 06:13AM, ABHISHEK SINGH TOMAR wrote: > From: Abhishek Singh Tomar <abhishek@linux.ibm.com> > <...snip...> > > - if (uart_read(REG_LSR) & LSR_THRE) { > + reg = uart_read(REG_LSR); > + if (reg & LSR_THRE && reg != 0xff) { Nitpick: Maybe we can have: ((reg & LSR_THRE) && (reg != 0xff)). That seems more clear at what is being compared. Thanks, - Aditya G
On Fri, Apr 11, 2025 at 03:11:45PM +0530, Aditya Gupta wrote: >On 25/04/10 06:13AM, ABHISHEK SINGH TOMAR wrote: >> From: Abhishek Singh Tomar <abhishek@linux.ibm.com> >> <...snip...> >> >> - if (uart_read(REG_LSR) & LSR_THRE) { >> + reg = uart_read(REG_LSR); >> + if (reg & LSR_THRE && reg != 0xff) { > >Nitpick: Maybe we can have: ((reg & LSR_THRE) && (reg != 0xff)). That >seems more clear at what is being compared. I think the most readable is to use two if statements: reg = uart_read(REG_LSR); if (reg == 0xff) return false; if (reg & LSR_THRE) { ... } Fixed the patch up as above and applied to master.
diff --git a/hw/lpc-uart.c b/hw/lpc-uart.c index a5ffc5f22..33955b29c 100644 --- a/hw/lpc-uart.c +++ b/hw/lpc-uart.c @@ -98,10 +98,12 @@ static inline void uart_write(unsigned int reg, uint8_t val) static bool uart_check_tx_room(void) { + uint8_t reg; + if (tx_room) return true; - - if (uart_read(REG_LSR) & LSR_THRE) { + reg = uart_read(REG_LSR); + if (reg & LSR_THRE && reg != 0xff) { /* FIFO is 16 entries */ tx_room = 16; tx_full = false;