Stefan Reinauer has uploaded this change for review. ( 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 --- M em100.c 1 file changed, 11 insertions(+), 6 deletions(-)
git pull ssh://review.coreboot.org:29418/em100 refs/changes/41/47841/1
diff --git a/em100.c b/em100.c index f7bbb2d..2866f91 100644 --- a/em100.c +++ b/em100.c @@ -1190,6 +1190,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,12 +1214,15 @@
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 < 10) { + if (trace) { + if (!read_spi_trace(em100, terminal, + address_offset)) + usb_errors++; + } else { + if (!read_spi_terminal(em100, 0)) + usb_errors++; + } }
if (!do_start && !do_stop)