aboutsummaryrefslogtreecommitdiff
path: root/src/jtag/drivers/mpsse.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/jtag/drivers/mpsse.c')
-rw-r--r--src/jtag/drivers/mpsse.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/jtag/drivers/mpsse.c b/src/jtag/drivers/mpsse.c
index 8924892..43e924e 100644
--- a/src/jtag/drivers/mpsse.c
+++ b/src/jtag/drivers/mpsse.c
@@ -22,6 +22,7 @@
#include "mpsse.h"
#include "helper/log.h"
+#include "helper/time_support.h"
#include <libusb.h>
/* Compatibility define for older libusb-1.0 */
@@ -892,6 +893,7 @@ int mpsse_flush(struct mpsse_ctx *ctx)
}
/* Polling loop, more or less taken from libftdi */
+ int64_t start = timeval_ms();
while (!write_result.done || !read_result.done) {
struct timeval timeout_usb;
@@ -914,6 +916,11 @@ int mpsse_flush(struct mpsse_ctx *ctx)
break;
}
}
+
+ if (timeval_ms() - start > 2000) {
+ LOG_ERROR("Timed out handling USB events in mpsse_flush().");
+ break;
+ }
}
error_check: