By just ignoring them and trying again later. This handles the
EGAIN case properly (the previous implementation was only dealing
with short returns and not errors).

Signed-off-by: Peter Crosthwaite <peter.crosthwa...@xilinx.com>
---

 hw/char/cadence_uart.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/hw/char/cadence_uart.c b/hw/char/cadence_uart.c
index 1012f1a..1985047 100644
--- a/hw/char/cadence_uart.c
+++ b/hw/char/cadence_uart.c
@@ -302,8 +302,11 @@ static gboolean cadence_uart_xmit(GIOChannel *chan, 
GIOCondition cond,
     }
 
     ret = qemu_chr_fe_write(s->chr, s->tx_fifo, s->tx_count);
-    s->tx_count -= ret;
-    memmove(s->tx_fifo, s->tx_fifo + ret, s->tx_count);
+
+    if (ret >= 0) {
+        s->tx_count -= ret;
+        memmove(s->tx_fifo, s->tx_fifo + ret, s->tx_count);
+    }
 
     if (s->tx_count) {
         int r = qemu_chr_fe_add_watch(s->chr, G_IO_OUT, cadence_uart_xmit, s);
-- 
1.8.5.4


Reply via email to