Author: hailfinger
Date: Wed Nov 10 04:10:41 2010
New Revision: 1228
URL: http://flashrom.org/trac/flashrom/changeset/1228

Log:
Retry short reads in ft2232_spi.
It is possible that ftdi_read_data() returns less data
than requested. Catch this case and retry reading the rest
of the buffer.

Signed-off-by: Alex Badea <[email protected]>
Acked-by: Carl-Daniel Hailfinger <[email protected]>

Modified:
   trunk/ft2232_spi.c

Modified: trunk/ft2232_spi.c
==============================================================================
--- trunk/ft2232_spi.c  Wed Nov 10 00:30:43 2010        (r1227)
+++ trunk/ft2232_spi.c  Wed Nov 10 04:10:41 2010        (r1228)
@@ -108,11 +108,16 @@
                   int size)
 {
        int r;
-       r = ftdi_read_data(ftdic, (unsigned char *) buf, size);
-       if (r < 0) {
-               msg_perr("ftdi_read_data: %d, %s\n", r,
-                               ftdi_get_error_string(ftdic));
-               return 1;
+
+       while (size > 0) {
+               r = ftdi_read_data(ftdic, (unsigned char *) buf, size);
+               if (r < 0) {
+                       msg_perr("ftdi_read_data: %d, %s\n", r,
+                                       ftdi_get_error_string(ftdic));
+                       return 1;
+               }
+               buf += r;
+               size -= r;
        }
        return 0;
 }

_______________________________________________
flashrom mailing list
[email protected]
http://www.flashrom.org/mailman/listinfo/flashrom

Reply via email to