diff options
| author | sakumisu <[email protected]> | 2025-11-24 20:34:16 +0800 |
|---|---|---|
| committer | sakumisu <[email protected]> | 2025-11-24 20:36:23 +0800 |
| commit | 47cc574730aa8d7966bfb62697f90785e556a13b (patch) | |
| tree | a65caedf3436432d786fc7e488182d70a2ea753f | |
| parent | 510b34aa3cd761cfc235787a34c22bfe20a79d16 (diff) | |
update(core): change assert with USB_ASSERT_MSG
Signed-off-by: sakumisu <[email protected]>
| -rw-r--r-- | core/usbd_core.c | 19 | ||||
| -rw-r--r-- | 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]; |
