@@ -265,13 +265,15 @@ static void free_bus_bandwidth(struct usb_hcd *hcd, uint32_t bw,
265
265
266
266
/**
267
267
* Sets the final status of an URB and returns it to the device driver. Any
268
- * required cleanup of the URB is performed.
268
+ * required cleanup of the URB is performed. The HCD lock should be held on
269
+ * entry.
269
270
*/
270
271
static int _complete (dwc_otg_hcd_t * hcd , void * urb_handle ,
271
272
dwc_otg_hcd_urb_t * dwc_otg_urb , int32_t status )
272
273
{
273
274
struct urb * urb = (struct urb * )urb_handle ;
274
275
urb_tq_entry_t * new_entry ;
276
+ int rc = 0 ;
275
277
if (CHK_DEBUG_LEVEL (DBG_HCDV | DBG_HCD_URB )) {
276
278
DWC_PRINTF ("%s: urb %p, device %d, ep %d %s, status=%d\n" ,
277
279
__func__ , urb , usb_pipedevice (urb -> pipe ),
@@ -363,9 +365,17 @@ static int _complete(dwc_otg_hcd_t * hcd, void *urb_handle,
363
365
#endif
364
366
} else {
365
367
new_entry -> urb = urb ;
366
- DWC_TAILQ_INSERT_TAIL (& hcd -> completed_urb_list , new_entry ,
367
- urb_tq_entries );
368
- DWC_TASK_HI_SCHEDULE (hcd -> completion_tasklet );
368
+ #if USB_URB_EP_LINKING
369
+ rc = usb_hcd_check_unlink_urb (dwc_otg_hcd_to_hcd (hcd ), urb , urb -> status );
370
+ if (0 == rc ) {
371
+ usb_hcd_unlink_urb_from_ep (dwc_otg_hcd_to_hcd (hcd ), urb );
372
+ }
373
+ #endif
374
+ if (0 == rc ) {
375
+ DWC_TAILQ_INSERT_TAIL (& hcd -> completed_urb_list , new_entry ,
376
+ urb_tq_entries );
377
+ DWC_TASK_HI_SCHEDULE (hcd -> completion_tasklet );
378
+ }
369
379
}
370
380
return 0 ;
371
381
}
0 commit comments