From f8f2f890d9cc1c81996fb83f7c131b0e1b78e262 Mon Sep 17 00:00:00 2001 From: Werner Almesberger Date: Mon, 20 Jun 2011 22:58:46 -0300 Subject: [PATCH] tools/lib/atusb-common.c (atusb_interrupt_wait): don't try to pull more irqs ausb_bulk_read may lose data when timing out. We therefore try to minimize the number of times we time out. Reading until no more interrupts arrive may have looked like a good idea, but it just causes trouble for now. --- tools/lib/atusb-common.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/tools/lib/atusb-common.c b/tools/lib/atusb-common.c index 6766eda..718a758 100644 --- a/tools/lib/atusb-common.c +++ b/tools/lib/atusb-common.c @@ -213,17 +213,14 @@ int atusb_interrupt_wait(void *handle, int timeout_ms) if (irq) timeout_ms = 1; - while (1) { - res = usb_bulk_read(dsc->dev, 1, - (char *) &buf, sizeof(buf), timeout_ms); - if (res == -ETIMEDOUT) - break; + res = usb_bulk_read(dsc->dev, 1, + (char *) &buf, sizeof(buf), timeout_ms); + if (res != -ETIMEDOUT) { if (res < 0) { fprintf(stderr, "usb_bulk_read: %d\n", res); dsc->error = 1; return 0; /* handle this via atrf_error */ } - timeout_ms = 1; for (i = 0; i != res; i++) irq |= buf[i]; }