Use fifo8_is_empty() and fifo8_is_full() to improve readability of the code.
Signed-off-by: Bernhard Beschow <[email protected]> --- hw/char/serial.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/hw/char/serial.c b/hw/char/serial.c index 0f2e79dfba..20f68fd2f8 100644 --- a/hw/char/serial.c +++ b/hw/char/serial.c @@ -239,7 +239,7 @@ static void serial_xmit(SerialState *s) if (s->fcr & UART_FCR_FE) { assert(!fifo8_is_empty(&s->xmit_fifo)); s->tsr = fifo8_pop(&s->xmit_fifo); - if (!s->xmit_fifo.num) { + if (fifo8_is_empty(&s->xmit_fifo)) { s->lsr |= UART_LSR_THRE; } } else { @@ -481,7 +481,7 @@ static uint64_t serial_ioport_read(void *opaque, hwaddr addr, unsigned size) if(s->fcr & UART_FCR_FE) { ret = fifo8_is_empty(&s->recv_fifo) ? 0 : fifo8_pop(&s->recv_fifo); - if (s->recv_fifo.num == 0) { + if (fifo8_is_empty(&s->recv_fifo)) { s->lsr &= ~(UART_LSR_DR | UART_LSR_BI); } else { timer_mod(s->fifo_timeout_timer, qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + s->char_transmit_time * 4); @@ -555,7 +555,7 @@ static uint64_t serial_ioport_read(void *opaque, hwaddr addr, unsigned size) static int serial_can_receive(SerialState *s) { if(s->fcr & UART_FCR_FE) { - if (s->recv_fifo.num < UART_FIFO_LENGTH) { + if (!fifo8_is_full(&s->recv_fifo)) { /* * Advertise (fifo.itl - fifo.count) bytes when count < ITL, and 1 * if above. If UART_FIFO_LENGTH - fifo.count is advertised the @@ -585,7 +585,7 @@ static void serial_receive_break(SerialState *s) /* There's data in recv_fifo and s->rbr has not been read for 4 char transmit times */ static void fifo_timeout_int (void *opaque) { SerialState *s = opaque; - if (s->recv_fifo.num) { + if (!fifo8_is_empty(&s->recv_fifo)) { s->timeout_ipending = 1; serial_update_irq(s); } -- 2.53.0
