diff mbox

[PULL,26/29] util/fifo8: clear fifo head upon reset

Message ID 1391875084-12772-27-git-send-email-peter.maydell@linaro.org
State Accepted
Commit 58892d4782bf516e8356e3adfe4fc9b10c397b2f
Headers show

Commit Message

Peter Maydell Feb. 8, 2014, 3:58 p.m. UTC
From: Beniamino Galvani <b.galvani@gmail.com>

To improve the predictability of fifo8_pop_buf(), the fifo head is set
to the start of data buffer upon a reset so that the first call to the
function will be able to retrieve all data in the fifo.

Signed-off-by: Beniamino Galvani <b.galvani@gmail.com>
Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 util/fifo8.c | 1 +
 1 file changed, 1 insertion(+)
diff mbox

Patch

diff --git a/util/fifo8.c b/util/fifo8.c
index a7503c2..6a43482 100644
--- a/util/fifo8.c
+++ b/util/fifo8.c
@@ -89,6 +89,7 @@  const uint8_t *fifo8_pop_buf(Fifo8 *fifo, uint32_t max, uint32_t *num)
 void fifo8_reset(Fifo8 *fifo)
 {
     fifo->num = 0;
+    fifo->head = 0;
 }
 
 bool fifo8_is_empty(Fifo8 *fifo)