fel: Fix USB timeout on large transfers
Trying to use oversized initrd files (20 MB or more) can fail with the "libusb usb_bulk_send error -1" error message. To address this problem, we can split the transfer into smaller chunks and the problem disappears. Effectively, this is a revert of the older "fel: Increase timeout to 60 seconds instead of splitting bulk transfers" commmit. Signed-off-by: Siarhei Siamashka <siarhei.siamashka@gmail.com> Acked-by: Hans de Goede <hdegoede@redhat.com>
This commit is contained in:
parent
e4b3da2b17
commit
eae30b2a16
5
fel.c
5
fel.c
@ -73,11 +73,14 @@ static void pr_info(const char *fmt, ...)
|
||||
}
|
||||
}
|
||||
|
||||
static const int AW_USB_MAX_BULK_SEND = 4 * 1024 * 1024; // 4 MiB per bulk request
|
||||
|
||||
void usb_bulk_send(libusb_device_handle *usb, int ep, const void *data, int length)
|
||||
{
|
||||
int rc, sent;
|
||||
while (length > 0) {
|
||||
rc = libusb_bulk_transfer(usb, ep, (void *)data, length, &sent, timeout);
|
||||
int len = length < AW_USB_MAX_BULK_SEND ? length : AW_USB_MAX_BULK_SEND;
|
||||
rc = libusb_bulk_transfer(usb, ep, (void *)data, len, &sent, timeout);
|
||||
if (rc != 0) {
|
||||
fprintf(stderr, "libusb usb_bulk_send error %d\n", rc);
|
||||
exit(2);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user