diff mbox series

[7/9] hw/char/mcf_uart: Use FIFO_DEPTH definition instead of magic values

Message ID 20250219210841.94797-8-philmd@linaro.org (mailing list archive)
State New
Headers show
Series hw/char: Improve RX FIFO depth uses | expand

Commit Message

Philippe Mathieu-Daudé Feb. 19, 2025, 9:08 p.m. UTC
Defines FIFO_DEPTH and use it, fixing coding style.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 hw/char/mcf_uart.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

Comments

Luc Michel Feb. 20, 2025, 8:24 a.m. UTC | #1
On 22:08 Wed 19 Feb     , Philippe Mathieu-Daudé wrote:
> Defines FIFO_DEPTH and use it, fixing coding style.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>

Reviewed-by: Luc Michel <luc.michel@amd.com>

> ---
>  hw/char/mcf_uart.c | 10 +++++++---
>  1 file changed, 7 insertions(+), 3 deletions(-)
> 
> diff --git a/hw/char/mcf_uart.c b/hw/char/mcf_uart.c
> index 980a12fcb7d..95f269ee9b7 100644
> --- a/hw/char/mcf_uart.c
> +++ b/hw/char/mcf_uart.c
> @@ -17,6 +17,8 @@
>  #include "chardev/char-fe.h"
>  #include "qom/object.h"
> 
> +#define FIFO_DEPTH 4
> +
>  struct mcf_uart_state {
>      SysBusDevice parent_obj;
> 
> @@ -27,7 +29,7 @@ struct mcf_uart_state {
>      uint8_t imr;
>      uint8_t bg1;
>      uint8_t bg2;
> -    uint8_t fifo[4];
> +    uint8_t fifo[FIFO_DEPTH];
>      uint8_t tb;
>      int current_mr;
>      int fifo_len;
> @@ -247,14 +249,16 @@ static void mcf_uart_reset(DeviceState *dev)
>  static void mcf_uart_push_byte(mcf_uart_state *s, uint8_t data)
>  {
>      /* Break events overwrite the last byte if the fifo is full.  */
> -    if (s->fifo_len == 4)
> +    if (s->fifo_len == FIFO_DEPTH) {
>          s->fifo_len--;
> +    }
> 
>      s->fifo[s->fifo_len] = data;
>      s->fifo_len++;
>      s->sr |= MCF_UART_RxRDY;
> -    if (s->fifo_len == 4)
> +    if (s->fifo_len == FIFO_DEPTH) {
>          s->sr |= MCF_UART_FFULL;
> +    }
> 
>      mcf_uart_update(s);
>  }
> --
> 2.47.1
> 

--
diff mbox series

Patch

diff --git a/hw/char/mcf_uart.c b/hw/char/mcf_uart.c
index 980a12fcb7d..95f269ee9b7 100644
--- a/hw/char/mcf_uart.c
+++ b/hw/char/mcf_uart.c
@@ -17,6 +17,8 @@ 
 #include "chardev/char-fe.h"
 #include "qom/object.h"
 
+#define FIFO_DEPTH 4
+
 struct mcf_uart_state {
     SysBusDevice parent_obj;
 
@@ -27,7 +29,7 @@  struct mcf_uart_state {
     uint8_t imr;
     uint8_t bg1;
     uint8_t bg2;
-    uint8_t fifo[4];
+    uint8_t fifo[FIFO_DEPTH];
     uint8_t tb;
     int current_mr;
     int fifo_len;
@@ -247,14 +249,16 @@  static void mcf_uart_reset(DeviceState *dev)
 static void mcf_uart_push_byte(mcf_uart_state *s, uint8_t data)
 {
     /* Break events overwrite the last byte if the fifo is full.  */
-    if (s->fifo_len == 4)
+    if (s->fifo_len == FIFO_DEPTH) {
         s->fifo_len--;
+    }
 
     s->fifo[s->fifo_len] = data;
     s->fifo_len++;
     s->sr |= MCF_UART_RxRDY;
-    if (s->fifo_len == 4)
+    if (s->fifo_len == FIFO_DEPTH) {
         s->sr |= MCF_UART_FFULL;
+    }
 
     mcf_uart_update(s);
 }