summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAllen Martin <amartin@nvidia.com>2013-07-31 16:10:45 -0700
committerAllen Martin <amartin@nvidia.com>2013-09-20 13:02:30 -0700
commit18ff730d529ae9060921693a85a3491794c2c8f9 (patch)
treee50b56d1f906c02c43d3a05cc21e87c3361210ec
parentda5d86f31fa39deddd178e3814baf60c06a0ae2c (diff)
downloadtegrarcm-18ff730d529ae9060921693a85a3491794c2c8f9.tar.gz
tegrarcm: Add timeout to USB xfers
This prevents tegrarcm from just hanging in the event that the target gets in some bad state and stops responding to USB (like downloading a bad BCT). Set default timeout to 1s which should be plenty long enough for the max xfer size of 4096 bytes. Signed-off-by: Allen Martin <amartin@nvidia.com> Reviewed-by: Stephen Warren <swarren@nvidia.com>
-rw-r--r--src/usb.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/usb.c b/src/usb.c
index 16f3d90..450bc80 100644
--- a/src/usb.c
+++ b/src/usb.c
@@ -34,6 +34,9 @@
#include "usb.h"
#include "debug.h"
+// USB xfer timeout in ms
+#define USB_TIMEOUT 1000
+
#define USB_XFER_MAX 4096
//
@@ -225,7 +228,7 @@ int usb_write(usb_device_t *usb, uint8_t *buf, int len)
while (len) {
chunk_size = MIN(len, USB_XFER_MAX);
ret = libusb_bulk_transfer(usb->handle, usb->endpt_out, buf,
- chunk_size, &actual_chunk, 0);
+ chunk_size, &actual_chunk, USB_TIMEOUT);
if (ret != LIBUSB_SUCCESS) {
dprintf("write failure: %d\n", ret);
return EIO;
@@ -252,7 +255,7 @@ int usb_read(usb_device_t *usb, uint8_t *buf, int len, int *actual_len)
while (len) {
chunk_size = MIN(len, USB_XFER_MAX);
ret = libusb_bulk_transfer(usb->handle, usb->endpt_in, buf,
- chunk_size, &actual_chunk, 0);
+ chunk_size, &actual_chunk, USB_TIMEOUT);
if (ret != LIBUSB_SUCCESS) {
dprintf("read failure: %d\n", ret);
return EIO;