Skip to contentSkip to conversation

hw/char/spapr_vty: Return amount of free buffer entries in vty_can_receive()

PATCH Applied Thomas Huth 2 participants 2 messages Nov 18, 2016 – Nov 21, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hw/char/spapr_vty: Return amount of free buffer entries in vty_can_receive()

The can_receive() callbacks of the character devices should return the amount of characters that can be accepted at once, not just a boolean value (which rather means only one character at a time).

---
 hw/char/spapr_vty.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/char/spapr_vty.c +1 -1
index 06b9b39..7c22b8b 100644
@@ -25,7 +25,7 @@ static int vty_can_receive(void *opaque)
 {
     VIOsPAPRVTYDevice *dev = VIO_SPAPR_VTY_DEVICE(opaque);
 
-    return (dev->in - dev->out) < VTERM_BUFSIZE;
+    return VTERM_BUFSIZE - (dev->in - dev->out);
 }
 
 static void vty_receive(void *opaque, const uint8_t *buf, int size)
Signature · 1 line
1.8.3.1
Applied
#1 lore raw
Quoted 5 lines · Thomas Huth

The can_receive() callbacks of the character devices should return the amount of characters that can be accepted at once, not just a boolean value (which rather means only one character at a time).

Applied to ppc-for-2.8, thanks.

Quoted 17 lines
---
 hw/char/spapr_vty.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/char/spapr_vty.c +1 -1
index 06b9b39..7c22b8b 100644
@@ -25,7 +25,7 @@ static int vty_can_receive(void *opaque)
 {
     VIOsPAPRVTYDevice *dev = VIO_SPAPR_VTY_DEVICE(opaque);
 
-    return (dev->in - dev->out) < VTERM_BUFSIZE;
+    return VTERM_BUFSIZE - (dev->in - dev->out);
 }
 
 static void vty_receive(void *opaque, const uint8_t *buf, int size)
Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson