summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRafaël Carré <rafael.carre@gmail.com>2011-12-31 20:08:29 +0000
committerRafaël Carré <rafael.carre@gmail.com>2011-12-31 20:08:29 +0000
commitc55672bcef79ee2ea389cf50696054295dab91ad (patch)
treea3595eca3cb5c513c8aa2035e066f3097e96b158
parentf016893aaa11c94f482df6d1de7276eaeb38e732 (diff)
downloadrockbox-c55672bcef79ee2ea389cf50696054295dab91ad.tar.gz
rockbox-c55672bcef79ee2ea389cf50696054295dab91ad.zip
usb-drv-as3525v2: cosmetics
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31501 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--firmware/target/arm/as3525/usb-drv-as3525v2.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/firmware/target/arm/as3525/usb-drv-as3525v2.c b/firmware/target/arm/as3525/usb-drv-as3525v2.c
index c3cf7f4d77..51207d8e96 100644
--- a/firmware/target/arm/as3525/usb-drv-as3525v2.c
+++ b/firmware/target/arm/as3525/usb-drv-as3525v2.c
@@ -40,9 +40,9 @@ static const uint8_t in_ep_list[] = {0, 1, 3, 5};
40static const uint8_t out_ep_list[] = {0, 2, 4}; 40static const uint8_t out_ep_list[] = {0, 2, 4};
41 41
42/* store per endpoint, per direction, information */ 42/* store per endpoint, per direction, information */
43struct usb_endpoint 43struct ep_type
44{ 44{
45 unsigned int len; /* length of the data buffer */ 45 unsigned int size; /* length of the data buffer */
46 struct semaphore complete; /* wait object */ 46 struct semaphore complete; /* wait object */
47 int8_t status; /* completion status (0 for success) */ 47 int8_t status; /* completion status (0 for success) */
48 bool active; /* true is endpoint has been requested (true for EP0) */ 48 bool active; /* true is endpoint has been requested (true for EP0) */
@@ -67,7 +67,7 @@ enum ep0state
67}; 67};
68 68
69/* endpoints[ep_num][DIR_IN/DIR_OUT] */ 69/* endpoints[ep_num][DIR_IN/DIR_OUT] */
70static struct usb_endpoint endpoints[USB_NUM_ENDPOINTS][2]; 70static struct ep_type endpoints[USB_NUM_ENDPOINTS][2];
71/* setup packet for EP0 */ 71/* setup packet for EP0 */
72 72
73/* USB control requests may be up to 64 bytes in size. 73/* USB control requests may be up to 64 bytes in size.
@@ -116,7 +116,7 @@ static void reset_endpoints(void)
116 for (unsigned i = 0; i < num_eps(dir == DIR_OUT); i++) 116 for (unsigned i = 0; i < num_eps(dir == DIR_OUT); i++)
117 { 117 {
118 int ep = ((dir == DIR_IN) ? in_ep_list : out_ep_list)[i]; 118 int ep = ((dir == DIR_IN) ? in_ep_list : out_ep_list)[i];
119 struct usb_endpoint *endpoint = &endpoints[ep][out]; 119 struct ep_type *endpoint = &endpoints[ep][out];
120 endpoint->active = false; 120 endpoint->active = false;
121 endpoint->busy = false; 121 endpoint->busy = false;
122 endpoint->status = -1; 122 endpoint->status = -1;
@@ -148,7 +148,7 @@ static void cancel_all_transfers(bool cancel_ep0)
148 for (unsigned i = !!cancel_ep0; i < num_eps(dir == DIR_OUT); i++) 148 for (unsigned i = !!cancel_ep0; i < num_eps(dir == DIR_OUT); i++)
149 { 149 {
150 int ep = ((dir == DIR_IN) ? in_ep_list : out_ep_list)[i]; 150 int ep = ((dir == DIR_IN) ? in_ep_list : out_ep_list)[i];
151 struct usb_endpoint *endpoint = &endpoints[ep][dir == DIR_OUT]; 151 struct ep_type *endpoint = &endpoints[ep][dir == DIR_OUT];
152 endpoint->status = -1; 152 endpoint->status = -1;
153 endpoint->busy = false; 153 endpoint->busy = false;
154 endpoint->done = false; 154 endpoint->done = false;
@@ -259,17 +259,17 @@ static void handle_ep_int(int ep, bool out)
259 259
260 if(sts & DEPINT_xfercompl) 260 if(sts & DEPINT_xfercompl)
261 { 261 {
262 struct usb_endpoint *endpoint = &endpoints[ep][out ? DIR_OUT : DIR_IN]; 262 struct ep_type *endpoint = &endpoints[ep][out ? DIR_OUT : DIR_IN];
263 if(endpoint->busy) 263 if(endpoint->busy)
264 { 264 {
265 endpoint->busy = false; 265 endpoint->busy = false;
266 endpoint->status = 0; 266 endpoint->status = 0;
267 /* works even for EP0 */ 267 /* works even for EP0 */
268 int size = (DEPTSIZ(ep, out) & DEPTSIZ_xfersize_bits); 268 int size = (DEPTSIZ(ep, out) & DEPTSIZ_xfersize_bits);
269 int transfered = endpoint->len - size; 269 int transfered = endpoint->size - size;
270 if(ep == 0) 270 if(ep == 0)
271 { 271 {
272 bool is_ack = endpoint->len == 0; 272 bool is_ack = endpoint->size == 0;
273 switch(ep0_state) 273 switch(ep0_state)
274 { 274 {
275 case EP0_WAIT_SETUP: 275 case EP0_WAIT_SETUP:
@@ -287,7 +287,7 @@ static void handle_ep_int(int ep, bool out)
287 } 287 }
288 } 288 }
289 if (!out) 289 if (!out)
290 endpoint->len = size; 290 endpoint->size = size;
291 usb_core_transfer_complete(ep, out ? USB_DIR_OUT : USB_DIR_IN, 0, transfered); 291 usb_core_transfer_complete(ep, out ? USB_DIR_OUT : USB_DIR_IN, 0, transfered);
292 endpoint->done = true; 292 endpoint->done = true;
293 semaphore_release(&endpoint->complete); 293 semaphore_release(&endpoint->complete);
@@ -428,9 +428,9 @@ static void usb_drv_transfer(int ep, void *ptr, int len, bool out)
428 /* disable interrupts to avoid any race */ 428 /* disable interrupts to avoid any race */
429 int oldlevel = disable_irq_save(); 429 int oldlevel = disable_irq_save();
430 430
431 struct usb_endpoint *endpoint = &endpoints[ep][out ? DIR_OUT : DIR_IN]; 431 struct ep_type *endpoint = &endpoints[ep][out ? DIR_OUT : DIR_IN];
432 endpoint->busy = true; 432 endpoint->busy = true;
433 endpoint->len = len; 433 endpoint->size = len;
434 endpoint->status = -1; 434 endpoint->status = -1;
435 435
436 if (out) 436 if (out)
@@ -467,7 +467,7 @@ int usb_drv_recv(int ep, void *ptr, int len)
467int usb_drv_send(int ep, void *ptr, int len) 467int usb_drv_send(int ep, void *ptr, int len)
468{ 468{
469 ep = EP_NUM(ep); 469 ep = EP_NUM(ep);
470 struct usb_endpoint *endpoint = &endpoints[ep][1]; 470 struct ep_type *endpoint = &endpoints[ep][1];
471 endpoint->done = false; 471 endpoint->done = false;
472 usb_drv_transfer(ep, ptr, len, false); 472 usb_drv_transfer(ep, ptr, len, false);
473 while (endpoint->busy && !endpoint->done) 473 while (endpoint->busy && !endpoint->done)