[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 26/28] util/fifo8: Introduce fifo8_drop()
From: |
Philippe Mathieu-Daudé |
Subject: |
[PULL 26/28] util/fifo8: Introduce fifo8_drop() |
Date: |
Tue, 23 Jul 2024 22:38:53 +0200 |
Add the fifo8_drop() helper for clarity.
It is a simple wrapper over fifo8_pop_buf().
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Reviewed-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Message-Id: <20240722160745.67904-8-philmd@linaro.org>
---
include/qemu/fifo8.h | 9 +++++++++
hw/scsi/esp.c | 2 +-
util/fifo8.c | 6 ++++++
3 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/include/qemu/fifo8.h b/include/qemu/fifo8.h
index bca6da306f7..d1d06754d84 100644
--- a/include/qemu/fifo8.h
+++ b/include/qemu/fifo8.h
@@ -131,6 +131,15 @@ const uint8_t *fifo8_pop_bufptr(Fifo8 *fifo, uint32_t max,
uint32_t *numptr);
*/
const uint8_t *fifo8_peek_bufptr(Fifo8 *fifo, uint32_t max, uint32_t *numptr);
+/**
+ * fifo8_drop:
+ * @fifo: FIFO to drop bytes
+ * @len: number of bytes to drop
+ *
+ * Drop (consume) bytes from a FIFO.
+ */
+void fifo8_drop(Fifo8 *fifo, uint32_t len);
+
/**
* fifo8_reset:
* @fifo: FIFO to reset
diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c
index 04c9a557b69..b7af8256232 100644
--- a/hw/scsi/esp.c
+++ b/hw/scsi/esp.c
@@ -351,7 +351,7 @@ static void do_message_phase(ESPState *s)
/* Ignore extended messages for now */
if (s->cmdfifo_cdb_offset) {
int len = MIN(s->cmdfifo_cdb_offset, fifo8_num_used(&s->cmdfifo));
- fifo8_pop_buf(&s->cmdfifo, NULL, len);
+ fifo8_drop(&s->cmdfifo, len);
s->cmdfifo_cdb_offset = 0;
}
}
diff --git a/util/fifo8.c b/util/fifo8.c
index a250ea9f804..1ffa19d900e 100644
--- a/util/fifo8.c
+++ b/util/fifo8.c
@@ -131,6 +131,12 @@ uint32_t fifo8_pop_buf(Fifo8 *fifo, uint8_t *dest,
uint32_t destlen)
return n1 + n2;
}
+void fifo8_drop(Fifo8 *fifo, uint32_t len)
+{
+ len -= fifo8_pop_buf(fifo, NULL, len);
+ assert(len == 0);
+}
+
bool fifo8_is_empty(Fifo8 *fifo)
{
return (fifo->num == 0);
--
2.41.0
- [PULL 19/28] hw/char/goldfish: Use DMA memory API, (continued)
- [PULL 19/28] hw/char/goldfish: Use DMA memory API, Philippe Mathieu-Daudé, 2024/07/23
- [PULL 17/28] dump: make range overlap check more readable, Philippe Mathieu-Daudé, 2024/07/23
- [PULL 20/28] chardev/char-fe: Document returned value on error, Philippe Mathieu-Daudé, 2024/07/23
- [PULL 21/28] util/fifo8: Fix style, Philippe Mathieu-Daudé, 2024/07/23
- [PULL 22/28] util/fifo8: Use fifo8_reset() in fifo8_create(), Philippe Mathieu-Daudé, 2024/07/23
- [PULL 23/28] util/fifo8: Rename fifo8_peek_buf() -> fifo8_peek_bufptr(), Philippe Mathieu-Daudé, 2024/07/23
- [PULL 24/28] util/fifo8: Rename fifo8_pop_buf() -> fifo8_pop_bufptr(), Philippe Mathieu-Daudé, 2024/07/23
- [PULL 25/28] util/fifo8: Expose fifo8_pop_buf(), Philippe Mathieu-Daudé, 2024/07/23
- [PULL 27/28] MAINTAINERS: Cover guest-agent in QAPI schema, Philippe Mathieu-Daudé, 2024/07/23
- [PULL 28/28] MAINTAINERS: Add myself as a reviewer of machine core, Philippe Mathieu-Daudé, 2024/07/23
- [PULL 26/28] util/fifo8: Introduce fifo8_drop(),
Philippe Mathieu-Daudé <=
- Re: [PULL 00/28] Misc HW+ patches for 2024-07-23, Richard Henderson, 2024/07/24