Stefan Reinauer has submitted this change. ( https://review.coreboot.org/c/em100/+/47841 )
Change subject: Limit USB errors in trace / terminal mode ......................................................................
Limit USB errors in trace / terminal mode
If the device gets into a bad state (or, say, gets disconnected), bail out after 10 errors instead of continuing ad infinitum.
Signed-off-by: Stefan Reinauer stefan.reinauer@coreboot.org Change-Id: I1474386c69d267dba3bccaa740213753c06fee0c Reviewed-on: https://review.coreboot.org/c/em100/+/47841 Reviewed-by: Angel Pons th3fanbus@gmail.com Tested-by: build bot (Jenkins) no-reply@coreboot.org --- M em100.c 1 file changed, 15 insertions(+), 6 deletions(-)
Approvals: build bot (Jenkins): Verified Angel Pons: Looks good to me, approved
diff --git a/em100.c b/em100.c index f7bbb2d..350b8db 100644 --- a/em100.c +++ b/em100.c @@ -25,6 +25,8 @@
#include "em100.h"
+#define MAX_USB_ERRORS 10 + TFILE *configs; char *database_version; int debug = 0; @@ -1190,6 +1192,8 @@ }
if (trace || terminal) { + int usb_errors = 0; + if ((holdpin == NULL) && (!set_hold_pin_state(em100, 3))) { printf("Error: Failed to set EM100 to input\n"); return 1; @@ -1212,13 +1216,18 @@
printf(". Press CTL-C to exit.\n\n");
- while (!do_exit_flag) { - if (trace) - read_spi_trace(em100, terminal, - address_offset); - else - read_spi_terminal(em100, 0); + while (!do_exit_flag && usb_errors < MAX_USB_ERRORS) { + if (trace) { + if (!read_spi_trace(em100, terminal, + address_offset)) + usb_errors++; + } else { + if (!read_spi_terminal(em100, 0)) + usb_errors++; + } } + if (usb_errors >= MAX_USB_ERRORS) + printf("Error: Bailed out with too many USB errors.\n");
if (!do_start && !do_stop) set_state(em100, 0);