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:
parent
db7afc59c9
commit
b9556e0fd4
15
ft2232_spi.c
15
ft2232_spi.c
@ -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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user