From 8a2d80a93cf8b1148696e652cbd1b7b44059b84b Mon Sep 17 00:00:00 2001 From: Werner Almesberger Date: Thu, 23 Jun 2011 13:14:39 -0300 Subject: [PATCH] tools/lib/atusb-common.c: updated for new interrupt handling in firmware - atusb-common.c (atusb_interrupt_wait): the atusb firmware no longer reads and accumulates IRQs for us. We now just wait for the notification, then read IRQ_STATUS. Let higher layers take care of retries and all that. - atusb-common.c (atusb_open): clear any pending interrupts --- tools/lib/atusb-common.c | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/tools/lib/atusb-common.c b/tools/lib/atusb-common.c index 718a758..8b2e12c 100644 --- a/tools/lib/atusb-common.c +++ b/tools/lib/atusb-common.c @@ -81,6 +81,8 @@ void *atusb_open(const char *arg) dsc->dev = dev; dsc->error = 0; + atusb_driver.reg_read(dsc, REG_IRQ_STATUS); + return dsc; } @@ -203,28 +205,23 @@ void atusb_slp_tr(void *handle, int on, int pulse) int atusb_interrupt_wait(void *handle, int timeout_ms) { struct atusb_dsc *dsc = handle; - uint8_t irq, buf[100]; - int res, i; + char buf; + int res; if (dsc->error) return 0; - irq = atusb_driver.reg_read(handle, REG_IRQ_STATUS); - if (irq) - timeout_ms = 1; - 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 */ - } - for (i = 0; i != res; i++) - irq |= buf[i]; + if (res == -ETIMEDOUT) + return 0; + if (res < 0) { + fprintf(stderr, "usb_bulk_read: %d\n", res); + dsc->error = 1; + return 0; /* handle this via atrf_error */ } - return irq; + + return atusb_driver.reg_read(handle, REG_IRQ_STATUS); }