From 47cc574730aa8d7966bfb62697f90785e556a13b Mon Sep 17 00:00:00 2001 From: sakumisu <1203593632@qq.com> Date: Mon, 24 Nov 2025 20:34:16 +0800 Subject: [PATCH] update(core): change assert with USB_ASSERT_MSG Signed-off-by: sakumisu <1203593632@qq.com> --- core/usbd_core.c | 19 +++++-------------- core/usbh_core.c | 12 ++---------- 2 files changed, 7 insertions(+), 24 deletions(-) diff --git a/core/usbd_core.c b/core/usbd_core.c index 3dd8c2ba..55ce46ea 100644 --- a/core/usbd_core.c +++ b/core/usbd_core.c @@ -1544,11 +1544,7 @@ int usbd_initialize(uint8_t busid, uintptr_t reg_base, void (*event_handler)(uin int ret; struct usbd_bus *bus; - if (busid >= CONFIG_USBDEV_MAX_BUS) { - USB_LOG_ERR("bus overflow\r\n"); - while (1) { - } - } + USB_ASSERT_MSG(busid < CONFIG_USBDEV_MAX_BUS, "bus overflow\r\n"); bus = &g_usbdev_bus[busid]; bus->reg_base = reg_base; @@ -1577,23 +1573,18 @@ int usbd_initialize(uint8_t busid, uintptr_t reg_base, void (*event_handler)(uin int usbd_deinitialize(uint8_t busid) { - if (busid >= CONFIG_USBDEV_MAX_BUS) { - USB_LOG_ERR("bus overflow\r\n"); - while (1) { - } - } + 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); - g_usbd_core[busid].intf_offset = 0; #ifdef CONFIG_USBDEV_EP0_THREAD - if (g_usbd_core[busid].usbd_ep0_mq) { - usb_osal_mq_delete(g_usbd_core[busid].usbd_ep0_mq); - } if (g_usbd_core[busid].usbd_ep0_thread) { usb_osal_thread_delete(g_usbd_core[busid].usbd_ep0_thread); } + if (g_usbd_core[busid].usbd_ep0_mq) { + usb_osal_mq_delete(g_usbd_core[busid].usbd_ep0_mq); + } #endif return 0; diff --git a/core/usbh_core.c b/core/usbh_core.c index 1f670952..1d312375 100644 --- a/core/usbh_core.c +++ b/core/usbh_core.c @@ -628,11 +628,7 @@ int usbh_initialize(uint8_t busid, uintptr_t reg_base, usbh_event_handler_t even { struct usbh_bus *bus; - if (busid >= CONFIG_USBHOST_MAX_BUS) { - USB_LOG_ERR("bus overflow\r\n"); - while (1) { - } - } + USB_ASSERT_MSG(busid < CONFIG_USBHOST_MAX_BUS, "bus overflow\r\n"); bus = &g_usbhost_bus[busid]; @@ -666,11 +662,7 @@ int usbh_deinitialize(uint8_t busid) { struct usbh_bus *bus; - if (busid >= CONFIG_USBHOST_MAX_BUS) { - USB_LOG_ERR("bus overflow\r\n"); - while (1) { - } - } + USB_ASSERT_MSG(busid < CONFIG_USBHOST_MAX_BUS, "bus overflow\r\n"); bus = &g_usbhost_bus[busid];