Skip to content

Commit 3d97aee

Browse files
committed
fix(core): adjust init&deinit event callback position
Signed-off-by: sakumisu <1203593632@qq.com>
1 parent 03c6bfe commit 3d97aee

3 files changed

Lines changed: 6 additions & 7 deletions

File tree

class/hub/usbh_hub.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -681,8 +681,9 @@ static void usbh_hub_thread(CONFIG_USB_OSAL_THREAD_SET_ARGV)
681681

682682
struct usbh_bus *bus = (struct usbh_bus *)CONFIG_USB_OSAL_THREAD_GET_ARGV;
683683

684-
usb_hc_init(bus);
685684
bus->event_handler(bus->busid, USB_HUB_INDEX_ANY, USB_HUB_PORT_ANY, USB_INTERFACE_ANY, USBH_EVENT_INIT);
685+
usb_hc_init(bus);
686+
686687
while (1) {
687688
ret = usb_osal_mq_recv(bus->hub_mq, (uintptr_t *)&hub, USB_OSAL_WAITING_FOREVER);
688689
if (ret < 0) {

core/usbd_core.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1364,18 +1364,16 @@ int usbd_initialize(uint8_t busid, uintptr_t reg_base, void (*event_handler)(uin
13641364
#endif
13651365

13661366
g_usbd_core[busid].event_handler = event_handler;
1367-
ret = usb_dc_init(busid);
13681367
usbd_class_event_notify_handler(busid, USBD_EVENT_INIT, NULL);
13691368
g_usbd_core[busid].event_handler(busid, USBD_EVENT_INIT);
1369+
ret = usb_dc_init(busid);
13701370
return ret;
13711371
}
13721372

13731373
int usbd_deinitialize(uint8_t busid)
13741374
{
13751375
USB_ASSERT_MSG(busid < CONFIG_USBDEV_MAX_BUS, "bus overflow\r\n");
13761376

1377-
g_usbd_core[busid].event_handler(busid, USBD_EVENT_DEINIT);
1378-
usbd_class_event_notify_handler(busid, USBD_EVENT_DEINIT, NULL);
13791377
usb_dc_deinit(busid);
13801378
#ifdef CONFIG_USBDEV_EP0_THREAD
13811379
if (g_usbd_core[busid].usbd_ep0_thread) {
@@ -1385,6 +1383,7 @@ int usbd_deinitialize(uint8_t busid)
13851383
usb_osal_mq_delete(g_usbd_core[busid].usbd_ep0_mq);
13861384
}
13871385
#endif
1388-
1386+
g_usbd_core[busid].event_handler(busid, USBD_EVENT_DEINIT);
1387+
usbd_class_event_notify_handler(busid, USBD_EVENT_DEINIT, NULL);
13891388
return 0;
13901389
}

core/usbh_core.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -666,9 +666,8 @@ int usbh_deinitialize(uint8_t busid)
666666

667667
bus = &g_usbhost_bus[busid];
668668

669-
bus->event_handler(bus->busid, USB_HUB_INDEX_ANY, USB_HUB_PORT_ANY, USB_INTERFACE_ANY, USBH_EVENT_DEINIT);
670-
671669
usbh_hub_deinitialize(bus);
670+
bus->event_handler(bus->busid, USB_HUB_INDEX_ANY, USB_HUB_PORT_ANY, USB_INTERFACE_ANY, USBH_EVENT_DEINIT);
672671

673672
usb_slist_remove(&g_bus_head, &bus->list);
674673

0 commit comments

Comments
 (0)