diff --git a/port/musb/usb_hc_musb.c b/port/musb/usb_hc_musb.c index 51887883..26a284be 100644 --- a/port/musb/usb_hc_musb.c +++ b/port/musb/usb_hc_musb.c @@ -630,6 +630,21 @@ int usbh_pipe_alloc(usbh_pipe_t *pipe, const struct usbh_endpoint_cfg *ep_cfg) int usbh_pipe_free(usbh_pipe_t pipe) { + struct musb_pipe *ppipe; + struct usbh_urb *urb; + + ppipe = (struct musb_pipe *)pipe; + + if (!ppipe) { + return -EINVAL; + } + + urb = ppipe->urb; + + if (urb) { + usbh_kill_urb(urb); + } + return 0; } @@ -704,6 +719,20 @@ errout_timeout: int usbh_kill_urb(struct usbh_urb *urb) { + struct musb_pipe *pipe; + + pipe = urb->pipe; + + if (!urb || !pipe) { + return -EINVAL; + } + + if (pipe->waiter) { + pipe->waiter = false; + urb->errorcode = -ESHUTDOWN; + usb_osal_sem_give(pipe->waitsem); + } + return 0; }