summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsakumisu <[email protected]>2022-10-05 12:22:23 +0800
committersakumisu <[email protected]>2022-10-05 12:47:05 +0800
commit0c77c8b457c7ab0f82d1e6f68f43ae5024930612 (patch)
tree13df357370bfca0b52c26b2b4df5d153cc012b91
parent6c25035d7acdc3e5dc6a4833d3c0ca998799b6e7 (diff)
start next hub int transfer after enumrateion
-rw-r--r--class/hub/usbh_hub.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/class/hub/usbh_hub.c b/class/hub/usbh_hub.c
index 4796bf45..b6211217 100644
--- a/class/hub/usbh_hub.c
+++ b/class/hub/usbh_hub.c
@@ -49,10 +49,8 @@ static int usbh_hub_devno_alloc(void)
return -EMFILE;
}
-static void usbh_hub_devno_free(struct usbh_hub *hub)
+static void usbh_hub_devno_free(uint8_t devno)
{
- int devno = hub->index;
-
if (devno >= EXTHUB_FIRST_INDEX && devno < 32) {
g_devinuse &= ~(1 << devno);
}
@@ -239,7 +237,6 @@ static void hub_int_complete_callback(void *arg, int nbytes)
if (nbytes > 0) {
usbh_hub_thread_wakeup(hub);
- usbh_submit_urb(&hub->intin_urb);
}
}
@@ -251,7 +248,9 @@ static int usbh_hub_connect(struct usbh_hubport *hport, uint8_t intf)
int index;
index = usbh_hub_devno_alloc();
- if (index > (CONFIG_USBHOST_MAX_EXTHUBS + EXTHUB_FIRST_INDEX)) {
+ if (index > (CONFIG_USBHOST_MAX_EXTHUBS + EXTHUB_FIRST_INDEX - 1)) {
+ USB_LOG_ERR("No memory to alloc hub class\r\n");
+ usbh_hub_devno_free(index);
return -ENOMEM;
}
@@ -316,7 +315,7 @@ static int usbh_hub_disconnect(struct usbh_hubport *hport, uint8_t intf)
struct usbh_hub *hub = (struct usbh_hub *)hport->config.intf[intf].priv;
if (hub) {
- usbh_hub_devno_free(hub);
+ usbh_hub_devno_free(hub->index);
if (hub->intin) {
usbh_pipe_free(hub->intin);
@@ -517,6 +516,11 @@ static void usbh_hub_events(struct usbh_hub *hub)
}
}
}
+
+ /* Start next hub int transfer */
+ if (!hub->is_roothub && hub->connected) {
+ usbh_submit_urb(&hub->intin_urb);
+ }
}
static void usbh_hub_thread(void *argument)