diff options
author | Tobias Diedrich <ranma+coreboot@tdiedrich.de> | 2010-06-24 19:14:47 +0000 |
---|---|---|
committer | Tobias Diedrich <ranma+coreboot@tdiedrich.de> | 2010-06-24 19:14:47 +0000 |
commit | c9bbff571b726c30d19aff824872f6193d7ae5d2 (patch) | |
tree | 5991c9c13a85e3b437e4078c28824b8ad54aa5ab | |
parent | a035ed4cb0848e07dbc4df82ca560aeb5a3935c3 (diff) |
Add transfer timeout, remove unused buf field
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27115 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | firmware/target/arm/as3525/usb-drv-as3525.c | 21 | ||||
-rw-r--r-- | firmware/target/arm/as3525/usb-drv-as3525.h | 2 |
2 files changed, 21 insertions, 2 deletions
diff --git a/firmware/target/arm/as3525/usb-drv-as3525.c b/firmware/target/arm/as3525/usb-drv-as3525.c index 90a1c931f7..09a680476d 100644 --- a/firmware/target/arm/as3525/usb-drv-as3525.c +++ b/firmware/target/arm/as3525/usb-drv-as3525.c @@ -413,7 +413,7 @@ int usb_drv_recv(int ep, void *ptr, int len) endpoints[ep][1].state |= EP_STATE_BUSY; endpoints[ep][1].len = len; endpoints[ep][1].rc = -1; - endpoints[ep][1].buf = ptr; + endpoints[ep][1].timeout = current_tick + HZ; /* remove data buffer from cache */ invalidate_dcache_range(ptr, len); @@ -483,6 +483,7 @@ void ep_send(int ep, void *ptr, int len) endpoints[ep][0].state |= EP_STATE_BUSY; endpoints[ep][0].len = len; endpoints[ep][0].rc = -1; + endpoints[ep][0].timeout = current_tick + HZ; /* Make sure data is committed to memory */ clean_dcache_range(ptr, len); @@ -673,6 +674,24 @@ static void usb_tick(void) { static int rde_timer = 0; static int rde_fails = 0; + struct usb_endpoint *eps = &endpoints[0][0]; + int i; + + for (i=0; i<2*USB_NUM_EPS; i++) { + if (!(eps[i].state & EP_STATE_BUSY) || + !TIME_AFTER(current_tick, endpoints[i])) + continue; + + /* recv or send timed out */ + if (eps[i].state & EP_STATE_ASYNC) { + eps[i].rc = -1; + wakeup_signal(&eps[i].complete); + } else { + usb_core_transfer_complete(i/2, i&1 ? USB_DIR_OUT : USB_DIR_IN, + -1, 0); + } + eps[i].state &= ~(EP_STATE_BUSY|EP_STATE_ASYNC); + } if (USB_DEV_CTRL & USB_DEV_CTRL_RDE) return; diff --git a/firmware/target/arm/as3525/usb-drv-as3525.h b/firmware/target/arm/as3525/usb-drv-as3525.h index d4ec8067ac..ee3b4fcd03 100644 --- a/firmware/target/arm/as3525/usb-drv-as3525.h +++ b/firmware/target/arm/as3525/usb-drv-as3525.h @@ -307,8 +307,8 @@ struct usb_dev_setup_buf { struct usb_endpoint { - void *buf; unsigned int len; + unsigned int timeout; volatile unsigned int state; int rc; struct wakeup complete; |