[PATCH 05/11] tegrarcm: Add timeout to USB xfers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
---
 src/usb.c | 7 +++++--
 1 file 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;
-- 
1.8.1.5

--
To unsubscribe from this list: send the line "unsubscribe linux-tegra" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [ARM Kernel]     [Linux ARM]     [Linux ARM MSM]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux