1
0
mirror of https://review.coreboot.org/flashrom.git synced 2025-04-27 15:12:36 +02:00

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>
This commit is contained in:
Alex Badea 2010-11-10 03:10:41 +00:00 committed by Carl-Daniel Hailfinger
parent db7afc59c9
commit b9556e0fd4

View File

@ -108,11 +108,16 @@ static int get_buf(struct ftdi_context *ftdic, const unsigned char *buf,
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;
}