Patchwork [11/16] qemu-char:fd insert poll call into read one

login
register
mail settings
Submitter Juan Quintela
Date March 11, 2010, 4:55 p.m.
Message ID <a86562cfdcb543fa61814de8390df3cdfad07708.1268326362.git.quintela@redhat.com>
Download mbox | patch
Permalink /patch/47357/
State New
Headers show

Comments

Juan Quintela - March 11, 2010, 4:55 p.m.
This way we can remove the poll test

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 qemu-char.c |   15 ++++-----------
 1 files changed, 4 insertions(+), 11 deletions(-)

Patch

diff --git a/qemu-char.c b/qemu-char.c
index 063da94..875f254 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -536,15 +536,6 @@  static int fd_chr_write(CharDriverState *chr, const uint8_t *buf, int len)
     return send_all(s->fd_out, buf, len);
 }

-static int fd_chr_read_poll(void *opaque)
-{
-    CharDriverState *chr = opaque;
-    FDCharDriver *s = chr->opaque;
-
-    s->max_size = qemu_chr_can_read(chr);
-    return s->max_size;
-}
-
 static void fd_chr_read(void *opaque)
 {
     CharDriverState *chr = opaque;
@@ -552,6 +543,9 @@  static void fd_chr_read(void *opaque)
     int size, len;
     uint8_t buf[READ_BUF_LEN];

+    s->max_size = qemu_chr_can_read(chr);
+    if (s->max_size <= 0)
+        return;
     len = sizeof(buf);
     if (len > s->max_size)
         len = s->max_size;
@@ -576,8 +570,7 @@  static void fd_chr_update_read_handler(CharDriverState *chr)
     if (s->fd_in >= 0) {
         if (display_type == DT_NOGRAPHIC && s->fd_in == 0) {
         } else {
-            qemu_set_fd_handler2(s->fd_in, fd_chr_read_poll,
-                                 fd_chr_read, NULL, chr);
+            qemu_set_fd_handler(s->fd_in, fd_chr_read, NULL, chr);
         }
     }
 }