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.

Corresponding to flashrom svn r1228.

Signed-off-by: Alex Badea <vamposdecampos@gmail.com>
Acked-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
diff --git a/ft2232_spi.c b/ft2232_spi.c
index a2ea2a8..7c2d9b5 100644
--- a/ft2232_spi.c
+++ b/ft2232_spi.c
@@ -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;
 }