Commit b9556e0f authored by Alex Badea's avatar Alex Badea Committed by Carl-Daniel Hailfinger
Browse files

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: default avatarAlex Badea <vamposdecampos@gmail.com>
Acked-by: default avatarCarl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
parent db7afc59
......@@ -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;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment