USB AMSv2: use status == -1 to signal errors

set status to failure before signaling usb_drv_send_nonblocking() in
reset_endpoints()

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@28037 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Rafaël Carré 2010-09-08 03:31:18 +00:00
parent d2871ff853
commit e526681c63

View file

@ -285,6 +285,7 @@ static void reset_endpoints(void)
{ {
endpoints[ep][DIR_IN].active = false; endpoints[ep][DIR_IN].active = false;
endpoints[ep][DIR_IN].busy = false; endpoints[ep][DIR_IN].busy = false;
endpoints[ep][DIR_IN].status = -1;
if(endpoints[ep][DIR_IN].wait) if(endpoints[ep][DIR_IN].wait)
wakeup_signal(&endpoints[ep][DIR_IN].complete); wakeup_signal(&endpoints[ep][DIR_IN].complete);
endpoints[ep][DIR_IN].wait = false; endpoints[ep][DIR_IN].wait = false;
@ -298,6 +299,7 @@ static void reset_endpoints(void)
{ {
endpoints[ep][DIR_OUT].active = false; endpoints[ep][DIR_OUT].active = false;
endpoints[ep][DIR_OUT].busy = false; endpoints[ep][DIR_OUT].busy = false;
endpoints[ep][DIR_OUT].status = -1;
if(endpoints[ep][DIR_OUT].wait) if(endpoints[ep][DIR_OUT].wait)
wakeup_signal(&endpoints[ep][DIR_OUT].complete); wakeup_signal(&endpoints[ep][DIR_OUT].complete);
endpoints[ep][DIR_OUT].wait = false; endpoints[ep][DIR_OUT].wait = false;
@ -324,7 +326,7 @@ static void cancel_all_transfers(bool cancel_ep0)
unsigned i, ep; unsigned i, ep;
FOR_EACH_IN_EP_EX(cancel_ep0, i, ep) FOR_EACH_IN_EP_EX(cancel_ep0, i, ep)
{ {
endpoints[ep][DIR_IN].status = 1; endpoints[ep][DIR_IN].status = -1;
endpoints[ep][DIR_IN].wait = false; endpoints[ep][DIR_IN].wait = false;
endpoints[ep][DIR_IN].busy = false; endpoints[ep][DIR_IN].busy = false;
wakeup_signal(&endpoints[ep][DIR_IN].complete); wakeup_signal(&endpoints[ep][DIR_IN].complete);
@ -332,7 +334,7 @@ static void cancel_all_transfers(bool cancel_ep0)
} }
FOR_EACH_OUT_EP_EX(cancel_ep0, i, ep) FOR_EACH_OUT_EP_EX(cancel_ep0, i, ep)
{ {
endpoints[ep][DIR_OUT].status = 1; endpoints[ep][DIR_OUT].status = -1;
endpoints[ep][DIR_OUT].wait = false; endpoints[ep][DIR_OUT].wait = false;
endpoints[ep][DIR_OUT].busy = false; endpoints[ep][DIR_OUT].busy = false;
wakeup_signal(&endpoints[ep][DIR_OUT].complete); wakeup_signal(&endpoints[ep][DIR_OUT].complete);
@ -498,7 +500,7 @@ static void handle_ep_int(int ep, bool dir_in)
if(endpoint->busy) if(endpoint->busy)
{ {
endpoint->busy = false; endpoint->busy = false;
endpoint->status = 1; endpoint->status = -1;
/* for safety, act as if no bytes as been transfered */ /* for safety, act as if no bytes as been transfered */
endpoint->len = 0; endpoint->len = 0;
usb_core_transfer_complete(ep, USB_DIR_IN, 1, 0); usb_core_transfer_complete(ep, USB_DIR_IN, 1, 0);
@ -746,7 +748,7 @@ static int usb_drv_transfer(int ep, void *ptr, int len, bool dir_in, bool blocki
endpoint->busy = true; endpoint->busy = true;
endpoint->len = len; endpoint->len = len;
endpoint->wait = blocking; endpoint->wait = blocking;
endpoint->status = 0; endpoint->status = -1;
DEPCTL &= ~DEPCTL_stall; DEPCTL &= ~DEPCTL_stall;
DEPCTL |= DEPCTL_usbactep; DEPCTL |= DEPCTL_usbactep;
@ -774,9 +776,11 @@ static int usb_drv_transfer(int ep, void *ptr, int len, bool dir_in, bool blocki
DEPCTL |= DEPCTL_epena | DEPCTL_cnak; DEPCTL |= DEPCTL_epena | DEPCTL_cnak;
if(blocking) if(blocking)
{
wakeup_wait(&endpoint->complete, TIMEOUT_BLOCK); wakeup_wait(&endpoint->complete, TIMEOUT_BLOCK);
if(endpoint->status != 0) return endpoint->status;
return -1; }
return 0; return 0;
#undef DEPCTL #undef DEPCTL
@ -831,4 +835,3 @@ bool usb_drv_stalled(int ep, bool in)
{ {
return (in ? DIEPCTL(ep) : DOEPCTL(ep)) & DEPCTL_stall; return (in ? DIEPCTL(ep) : DOEPCTL(ep)) & DEPCTL_stall;
} }