summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/usbd_core.c19
-rw-r--r--core/usbh_core.c12
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 7eefc53e..c66971b4 100644
--- a/core/usbh_core.c
+++ b/core/usbh_core.c
@@ -611,11 +611,7 @@ int usbh_initialize(uint8_t busid, uintptr_t reg_base)
{
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];
@@ -643,11 +639,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];