diff mbox

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

Message ID 1479460177-9362-1-git-send-email-thuth@redhat.com
State New
Headers show

Commit Message

Thomas Huth Nov. 18, 2016, 9:09 a.m. UTC
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).

Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 hw/char/spapr_vty.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

David Gibson Nov. 21, 2016, 2:30 a.m. UTC | #1
On Fri, Nov 18, 2016 at 10:09:37AM +0100, Thomas Huth wrote:
> 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).
> 
> Signed-off-by: Thomas Huth <thuth@redhat.com>

Applied to ppc-for-2.8, thanks.

> ---
>  hw/char/spapr_vty.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/hw/char/spapr_vty.c b/hw/char/spapr_vty.c
> index 06b9b39..7c22b8b 100644
> --- a/hw/char/spapr_vty.c
> +++ b/hw/char/spapr_vty.c
> @@ -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)
diff mbox

Patch

diff --git a/hw/char/spapr_vty.c b/hw/char/spapr_vty.c
index 06b9b39..7c22b8b 100644
--- a/hw/char/spapr_vty.c
+++ b/hw/char/spapr_vty.c
@@ -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)