summaryrefslogtreecommitdiff
path: root/drivers/serial/sandbox.c
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2025-04-03 16:54:59 -0600
committerTom Rini <trini@konsulko.com>2025-04-03 16:54:59 -0600
commit1aa8b03c01f72cefee31039571f2de2f4ccfe0eb (patch)
tree06e5b9076311df8043ff67124427c1dee11e952c /drivers/serial/sandbox.c
parent1f2a3d066c99f57675162ce09586e9de30407f1b (diff)
parentda8694a7d2cc9fdfd67e8a039ba1e70bdd543d0b (diff)
Merge patch series "membuff: Add tests and update to support a flag for empty/full"
Simon Glass <sjg@chromium.org> says: The membuff implementation curently has no tests. It also assumes that head and tail can never correspond unless the buffer is empty. This series provides a compile-time flag to support a 'full' flag. It also adds some tests of the main routines. The data structure is also renamed to membuf which fits better with U-Boot. There may be some cases in the code which could be optimised a little, but the implementation is functional. Link: https://lore.kernel.org/r/20250318152059.1464369-1-sjg@chromium.org
Diffstat (limited to 'drivers/serial/sandbox.c')
-rw-r--r--drivers/serial/sandbox.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/drivers/serial/sandbox.c b/drivers/serial/sandbox.c
index 77a1558db68..cc0491bc3c8 100644
--- a/drivers/serial/sandbox.c
+++ b/drivers/serial/sandbox.c
@@ -63,7 +63,7 @@ static int sandbox_serial_probe(struct udevice *dev)
if (state->term_raw != STATE_TERM_RAW)
disable_ctrlc(1);
- membuff_init(&priv->buf, priv->serial_buf, sizeof(priv->serial_buf));
+ membuf_init(&priv->buf, priv->serial_buf, sizeof(priv->serial_buf));
return 0;
}
@@ -138,15 +138,15 @@ static int sandbox_serial_pending(struct udevice *dev, bool input)
return 0;
os_usleep(100);
- avail = membuff_putraw(&priv->buf, 100, false, &data);
+ avail = membuf_putraw(&priv->buf, 100, false, &data);
if (!avail)
return 1; /* buffer full */
count = os_read(0, data, avail);
if (count > 0)
- membuff_putraw(&priv->buf, count, true, &data);
+ membuf_putraw(&priv->buf, count, true, &data);
- return membuff_avail(&priv->buf);
+ return membuf_avail(&priv->buf);
}
static int sandbox_serial_getc(struct udevice *dev)
@@ -156,7 +156,7 @@ static int sandbox_serial_getc(struct udevice *dev)
if (!sandbox_serial_pending(dev, true))
return -EAGAIN; /* buffer empty */
- return membuff_getbyte(&priv->buf);
+ return membuf_getbyte(&priv->buf);
}
#ifdef CONFIG_DEBUG_UART_SANDBOX