]> git.proxmox.com Git - grub2.git/commitdiff
fix losing pl2303 input at the price of losing some input bytes sometimes.
authorVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Sun, 18 Jul 2010 22:12:59 +0000 (00:12 +0200)
committerVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Sun, 18 Jul 2010 22:12:59 +0000 (00:12 +0200)
bus/usb/serial/pl2303.c
include/grub/serial.h

index ae1a4c1b3fd3411643b9b4efdd959fa63ee79aee..e2dcd606e5be788a82275d6cbde34034930b68d7 100644 (file)
@@ -127,17 +127,26 @@ real_config (struct grub_serial_port *port)
 static int
 pl2303_hw_fetch (struct grub_serial_port *port)
 {
-  char cc;
   grub_usb_err_t err;
 
   real_config (port);
 
+  if (port->bufstart < port->bufend)
+    return port->buf[port->bufstart++];
+
   err = grub_usb_bulk_read_timeout (port->usbdev, port->in_endp->endp_addr,
-                                   1, &cc, 10);
+                                   sizeof (port->buf), port->buf, 10);
   if (err != GRUB_USB_ERR_NONE)
     return -1;
 
-  return cc;
+  port->bufstart = 0;
+  /* FIXME: nearly always only one byte is transfered.
+     It happens however that more are transfered.
+     Setting sizeof (port->buf) to 1 leads code to stop reading after
+     such transfer.  */
+  port->bufend = 1;
+
+  return port->buf[port->bufstart++];
 }
 
 /* Put a character.  */
index fd601a6d940cf1b5b4ba011444ee252a53811972..a7d37c7de2ba1e233a701905b5df1f12cc05b0ef 100644 (file)
@@ -67,6 +67,8 @@ struct grub_serial_port
   struct grub_serial_driver *driver;
   struct grub_serial_config config;
   int configured;
+  char buf[64];
+  int bufstart, bufend;
   /* This should be void *data but since serial is useful as an early console
      when malloc isn't available it's a union.
    */