From 3ab47e02958a04db3fc39052ff7fcde05bdf954d Mon Sep 17 00:00:00 2001 From: sakumisu <1203593632@qq.com> Date: Wed, 6 Aug 2025 21:20:05 +0800 Subject: [PATCH] feat(port): add urb->complete in usbh_kill_urb Signed-off-by: sakumisu <1203593632@qq.com> --- port/dwc2/usb_hc_dwc2.c | 4 ++++ port/ehci/usb_hc_ehci.c | 7 ++++++- port/musb/usb_hc_musb.c | 4 ++++ port/rp2040/usb_hc_rp2040.c | 4 ++++ 4 files changed, 18 insertions(+), 1 deletion(-) diff --git a/port/dwc2/usb_hc_dwc2.c b/port/dwc2/usb_hc_dwc2.c index 681a6d75..df706eda 100644 --- a/port/dwc2/usb_hc_dwc2.c +++ b/port/dwc2/usb_hc_dwc2.c @@ -1139,6 +1139,10 @@ int usbh_kill_urb(struct usbh_urb *urb) dwc2_chan_free(chan); } + if (urb->complete) { + urb->complete(urb->arg, urb->errorcode); + } + usb_osal_leave_critical_section(flags); return 0; diff --git a/port/ehci/usb_hc_ehci.c b/port/ehci/usb_hc_ehci.c index 398d2430..2ebe1134 100644 --- a/port/ehci/usb_hc_ehci.c +++ b/port/ehci/usb_hc_ehci.c @@ -1350,7 +1350,8 @@ int usbh_kill_urb(struct usbh_urb *urb) EHCI_HCOR->usbcmd |= EHCI_USBCMD_IAAD; while (!(EHCI_HCOR->usbsts & EHCI_USBSTS_IAA)) { timeout++; - if (timeout > 20000) { + if (timeout > 200000) { + USB_LOG_ERR("iaad timeout\r\n"); usb_osal_leave_critical_section(flags); return -USB_ERR_TIMEOUT; } @@ -1358,6 +1359,10 @@ int usbh_kill_urb(struct usbh_urb *urb) EHCI_HCOR->usbsts = EHCI_USBSTS_IAA; } + if (urb->complete) { + urb->complete(urb->arg, urb->errorcode); + } + usb_osal_leave_critical_section(flags); return 0; diff --git a/port/musb/usb_hc_musb.c b/port/musb/usb_hc_musb.c index 2862f854..04798afb 100644 --- a/port/musb/usb_hc_musb.c +++ b/port/musb/usb_hc_musb.c @@ -820,6 +820,10 @@ int usbh_kill_urb(struct usbh_urb *urb) musb_pipe_free(pipe); } + if (urb->complete) { + urb->complete(urb->arg, urb->errorcode); + } + usb_osal_leave_critical_section(flags); return 0; } diff --git a/port/rp2040/usb_hc_rp2040.c b/port/rp2040/usb_hc_rp2040.c index 14764fb3..e9751b88 100644 --- a/port/rp2040/usb_hc_rp2040.c +++ b/port/rp2040/usb_hc_rp2040.c @@ -605,6 +605,10 @@ int usbh_kill_urb(struct usbh_urb *urb) rp2040_pipe_free(pipe); } + if (urb->complete) { + urb->complete(urb->arg, urb->errorcode); + } + usb_osal_leave_critical_section(flags); return 0;