release sources when enable port fails
This commit is contained in:
@@ -333,7 +333,7 @@ static int usbh_hub_disconnect(struct usbh_hubport *hport, uint8_t intf)
|
|||||||
usbh_hport_deactivate_ep0(child);
|
usbh_hport_deactivate_ep0(child);
|
||||||
for (uint8_t i = 0; i < child->config.config_desc.bNumInterfaces; i++) {
|
for (uint8_t i = 0; i < child->config.config_desc.bNumInterfaces; i++) {
|
||||||
if (child->config.intf[i].class_driver && child->config.intf[i].class_driver->disconnect) {
|
if (child->config.intf[i].class_driver && child->config.intf[i].class_driver->disconnect) {
|
||||||
ret = CLASS_DISCONNECT(child, i);
|
CLASS_DISCONNECT(child, i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -477,16 +477,15 @@ static void usbh_hub_events(struct usbh_hub *hub)
|
|||||||
}
|
}
|
||||||
|
|
||||||
child = &hub->child[port];
|
child = &hub->child[port];
|
||||||
|
|
||||||
/* if last status is connected, free sources first, this does not happen normally,
|
|
||||||
but there may be hardware issues in some ips */
|
|
||||||
if (child->connected) {
|
if (child->connected) {
|
||||||
|
child->connected = false;
|
||||||
usbh_hport_deactivate_ep0(child);
|
usbh_hport_deactivate_ep0(child);
|
||||||
for (uint8_t i = 0; i < child->config.config_desc.bNumInterfaces; i++) {
|
for (uint8_t i = 0; i < child->config.config_desc.bNumInterfaces; i++) {
|
||||||
if (child->config.intf[i].class_driver && child->config.intf[i].class_driver->disconnect) {
|
if (child->config.intf[i].class_driver && child->config.intf[i].class_driver->disconnect) {
|
||||||
CLASS_DISCONNECT(child, i);
|
CLASS_DISCONNECT(child, i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
child->config.config_desc.bNumInterfaces = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(child, 0, sizeof(struct usbh_hubport));
|
memset(child, 0, sizeof(struct usbh_hubport));
|
||||||
@@ -502,6 +501,18 @@ static void usbh_hub_events(struct usbh_hub *hub)
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
USB_LOG_ERR("Failed to enable port %u\r\n", port + 1);
|
USB_LOG_ERR("Failed to enable port %u\r\n", port + 1);
|
||||||
|
|
||||||
|
child = &hub->child[port];
|
||||||
|
if (child->connected) {
|
||||||
|
child->connected = false;
|
||||||
|
usbh_hport_deactivate_ep0(child);
|
||||||
|
for (uint8_t i = 0; i < child->config.config_desc.bNumInterfaces; i++) {
|
||||||
|
if (child->config.intf[i].class_driver && child->config.intf[i].class_driver->disconnect) {
|
||||||
|
CLASS_DISCONNECT(child, i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
child->config.config_desc.bNumInterfaces = 0;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -597,4 +608,4 @@ CLASS_INFO_DEFINE const struct usbh_class_info hub_info = {
|
|||||||
.pid = 0x00,
|
.pid = 0x00,
|
||||||
.class_driver = &hub_driver
|
.class_driver = &hub_driver
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user