Date:2011-06-23 18:14:39 (8 years 2 months ago)
Author:Werner Almesberger
Commit:8a2d80a93cf8b1148696e652cbd1b7b44059b84b
Message: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
Files: tools/lib/atusb-common.c (2 diffs)

Change Details

tools/lib/atusb-common.c
8181    dsc->dev = dev;
8282    dsc->error = 0;
8383
84    atusb_driver.reg_read(dsc, REG_IRQ_STATUS);
85
8486    return dsc;
8587}
8688
...... 
203205int atusb_interrupt_wait(void *handle, int timeout_ms)
204206{
205207    struct atusb_dsc *dsc = handle;
206    uint8_t irq, buf[100];
207    int res, i;
208    char buf;
209    int res;
208210
209211    if (dsc->error)
210212        return 0;
211213
212    irq = atusb_driver.reg_read(handle, REG_IRQ_STATUS);
213    if (irq)
214        timeout_ms = 1;
215
216214    res = usb_bulk_read(dsc->dev, 1,
217215        (char *) &buf, sizeof(buf), timeout_ms);
218    if (res != -ETIMEDOUT) {
219        if (res < 0) {
220            fprintf(stderr, "usb_bulk_read: %d\n", res);
221            dsc->error = 1;
222            return 0; /* handle this via atrf_error */
223        }
224        for (i = 0; i != res; i++)
225            irq |= buf[i];
216    if (res == -ETIMEDOUT)
217        return 0;
218    if (res < 0) {
219        fprintf(stderr, "usb_bulk_read: %d\n", res);
220        dsc->error = 1;
221        return 0; /* handle this via atrf_error */
226222    }
227    return irq;
223
224    return atusb_driver.reg_read(handle, REG_IRQ_STATUS);
228225}
229226
230227

Archive Download the corresponding diff file



interactive