diff options
Diffstat (limited to 'class/hub')
| -rw-r--r-- | class/hub/usbh_hub.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/class/hub/usbh_hub.c b/class/hub/usbh_hub.c index 98e9f0e2..afcfdcc2 100644 --- a/class/hub/usbh_hub.c +++ b/class/hub/usbh_hub.c @@ -329,6 +329,7 @@ static int usbh_hub_connect(struct usbh_hubport *hport, uint8_t intf) { struct usb_endpoint_descriptor *ep_desc; struct hub_port_status port_status; + uint8_t nports; int ret; struct usbh_hub *hub = usbh_hub_class_alloc(); @@ -372,7 +373,7 @@ static int usbh_hub_connect(struct usbh_hubport *hport, uint8_t intf) } parse_hub_ss_descriptor(&hub->hub_ss_desc, USB_SIZEOF_HUB_SS_DESC); - hub->nports = hub->hub_ss_desc.bNbrPorts; + nports = hub->hub_ss_desc.bNbrPorts; hub->powerdelay = hub->hub_ss_desc.bPwrOn2PwrGood * 2; hub->tt_think = 0U; } else { @@ -382,16 +383,17 @@ static int usbh_hub_connect(struct usbh_hubport *hport, uint8_t intf) } parse_hub_descriptor(&hub->hub_desc, USB_SIZEOF_HUB_DESC); - hub->nports = hub->hub_desc.bNbrPorts; + nports = hub->hub_desc.bNbrPorts; hub->powerdelay = hub->hub_desc.bPwrOn2PwrGood * 2; hub->tt_think = ((hub->hub_desc.wHubCharacteristics & HUB_CHAR_TTTT_MASK) >> 5); } - if (hub->nports > CONFIG_USBHOST_MAX_EHPORTS) { - USB_LOG_ERR("Hub nports %u overflow\r\n", hub->nports); + if (nports > CONFIG_USBHOST_MAX_EHPORTS) { + USB_LOG_ERR("Hub nports %u overflow\r\n", nports); return -USB_ERR_NOMEM; } + hub->nports = nports; for (uint8_t port = 0; port < hub->nports; port++) { hub->child[port].port = port + 1; hub->child[port].parent = hub; @@ -528,7 +530,7 @@ static void usbh_hub_events(struct usbh_hub *hub) ret = usbh_hub_clear_feature(hub, port + 1, feat); if (ret < 0) { USB_LOG_ERR("Failed to clear port %u, change mask:%04x, errorcode:%d\r\n", port + 1, mask, ret); - continue; + break; } portchange &= (~mask); } |
