summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsakumisu <[email protected]>2026-04-03 18:45:51 +0800
committersakumisu <[email protected]>2026-04-03 18:45:51 +0800
commit3d97aeebdef5d8a8ec3907d3f4f44816d49cd76e (patch)
tree7938d3b35d8e8e4abf8320f151e1b3452030be5b
parent03c6bfed39a4dbdb0b342172b5ece6d9435c4b5b (diff)
fix(core): adjust init&deinit event callback position
Signed-off-by: sakumisu <[email protected]>
-rw-r--r--class/hub/usbh_hub.c3
-rw-r--r--core/usbd_core.c7
-rw-r--r--core/usbh_core.c3
3 files changed, 6 insertions, 7 deletions
diff --git a/class/hub/usbh_hub.c b/class/hub/usbh_hub.c
index 910aa0c2..cef8d55b 100644
--- a/class/hub/usbh_hub.c
+++ b/class/hub/usbh_hub.c
@@ -681,8 +681,9 @@ static void usbh_hub_thread(CONFIG_USB_OSAL_THREAD_SET_ARGV)
struct usbh_bus *bus = (struct usbh_bus *)CONFIG_USB_OSAL_THREAD_GET_ARGV;
- usb_hc_init(bus);
bus->event_handler(bus->busid, USB_HUB_INDEX_ANY, USB_HUB_PORT_ANY, USB_INTERFACE_ANY, USBH_EVENT_INIT);
+ usb_hc_init(bus);
+
while (1) {
ret = usb_osal_mq_recv(bus->hub_mq, (uintptr_t *)&hub, USB_OSAL_WAITING_FOREVER);
if (ret < 0) {
diff --git a/core/usbd_core.c b/core/usbd_core.c
index bdbcfd07..a9ad67c4 100644
--- a/core/usbd_core.c
+++ b/core/usbd_core.c
@@ -1364,9 +1364,9 @@ int usbd_initialize(uint8_t busid, uintptr_t reg_base, void (*event_handler)(uin
#endif
g_usbd_core[busid].event_handler = event_handler;
- ret = usb_dc_init(busid);
usbd_class_event_notify_handler(busid, USBD_EVENT_INIT, NULL);
g_usbd_core[busid].event_handler(busid, USBD_EVENT_INIT);
+ ret = usb_dc_init(busid);
return ret;
}
@@ -1374,8 +1374,6 @@ int usbd_deinitialize(uint8_t busid)
{
USB_ASSERT_MSG(busid < CONFIG_USBDEV_MAX_BUS, "bus overflow\r\n");
- g_usbd_core[busid].event_handler(busid, USBD_EVENT_DEINIT);
- usbd_class_event_notify_handler(busid, USBD_EVENT_DEINIT, NULL);
usb_dc_deinit(busid);
#ifdef CONFIG_USBDEV_EP0_THREAD
if (g_usbd_core[busid].usbd_ep0_thread) {
@@ -1385,6 +1383,7 @@ int usbd_deinitialize(uint8_t busid)
usb_osal_mq_delete(g_usbd_core[busid].usbd_ep0_mq);
}
#endif
-
+ g_usbd_core[busid].event_handler(busid, USBD_EVENT_DEINIT);
+ usbd_class_event_notify_handler(busid, USBD_EVENT_DEINIT, NULL);
return 0;
}
diff --git a/core/usbh_core.c b/core/usbh_core.c
index 15ec7fee..966bafa5 100644
--- a/core/usbh_core.c
+++ b/core/usbh_core.c
@@ -666,9 +666,8 @@ int usbh_deinitialize(uint8_t busid)
bus = &g_usbhost_bus[busid];
- bus->event_handler(bus->busid, USB_HUB_INDEX_ANY, USB_HUB_PORT_ANY, USB_INTERFACE_ANY, USBH_EVENT_DEINIT);
-
usbh_hub_deinitialize(bus);
+ bus->event_handler(bus->busid, USB_HUB_INDEX_ANY, USB_HUB_PORT_ANY, USB_INTERFACE_ANY, USBH_EVENT_DEINIT);
usb_slist_remove(&g_bus_head, &bus->list);