hw/char/serial: Reuse fifo8_num_used()
Avoids accessing private fields of struct Fifo8. Now, TYPE_SERIAL only accesses struct Fifo8 through its methods. Signed-off-by: Bernhard Beschow <shentey@gmail.com> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Message-ID: <20260305220911.131508-8-shentey@gmail.com> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Bernhard Beschow committed
Mar 5, 2026 at 23:09 UTC
9f8caee699c955bae5266ac33e02f12bbe7bccab
1 file changed
+3
-3
hw/char/serial.c
+3
-3
@@ -128,7 +128,7 @@ static void serial_update_irq(SerialState *s)
128
tmp_iir = UART_IIR_CTI;
129
} else if ((s->ier & UART_IER_RDI) && (s->lsr & UART_LSR_DR) &&
130
(!(s->fcr & UART_FCR_FE) ||
131
- s->recv_fifo.num >= s->recv_fifo_itl)) {
131
+ fifo8_num_used(&s->recv_fifo) >= s->recv_fifo_itl)) {
132
tmp_iir = UART_IIR_RDI;
133
} else if ((s->ier & UART_IER_THRI) && s->thr_ipending) {
134
tmp_iir = UART_IIR_THRI;
@@ -563,8 +563,8 @@ static int serial_can_receive(SerialState *s)
563
* the guest has a chance to respond, effectively overriding the ITL
564
* that the guest has set.
565
*/
566
- return (s->recv_fifo.num <= s->recv_fifo_itl) ?
567
- s->recv_fifo_itl - s->recv_fifo.num : 1;
566
+ return (fifo8_num_used(&s->recv_fifo) <= s->recv_fifo_itl) ?
567
+ s->recv_fifo_itl - fifo8_num_used(&s->recv_fifo) : 1;
568
} else {
569
return 0;
570
}