summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsakumisu <[email protected]>2023-11-24 21:09:37 +0800
committersakumisu <[email protected]>2023-11-24 21:09:45 +0800
commit8e0c5b4e7ef7e9a83a33e537e789f6c8e7e89557 (patch)
tree47621b275cbaa72c7cfd8ed6c1cc8827de111a8d
parent8ae4453ca43f505a3f360bfddfda1ea7d81fc6aa (diff)
find roothub port to check if device is connecting
-rw-r--r--port/ehci/usb_hc_ehci.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/port/ehci/usb_hc_ehci.c b/port/ehci/usb_hc_ehci.c
index 4d9b588b..bf7395b1 100644
--- a/port/ehci/usb_hc_ehci.c
+++ b/port/ehci/usb_hc_ehci.c
@@ -1081,12 +1081,22 @@ int usbh_submit_urb(struct usbh_urb *urb)
struct ehci_qh_hw *qh = NULL;
size_t flags;
int ret = 0;
+ struct usbh_hub *hub;
+ struct usbh_hubport *hport;
if (!urb || !urb->hport || !urb->ep) {
return -EINVAL;
}
- if (!urb->hport->connected) {
+ /* find active hubport in roothub */
+ hport = urb->hport;
+ hub = urb->hport->parent;
+ while (!hub->is_roothub) {
+ hport = hub->parent;
+ hub = hub->parent->parent;
+ }
+
+ if (!urb->hport->connected || !(EHCI_HCOR->portsc[hport->port -1] & EHCI_PORTSC_CCS)) {
return -ENODEV;
}
@@ -1141,7 +1151,7 @@ int usbh_submit_urb(struct usbh_urb *urb)
}
urb->timeout = 0;
ret = urb->errorcode;
- /* we should free qh when waitsem is done */
+ /* we can free qh when waitsem is done */
ehci_qh_free(qh);
}
return ret;