summaryrefslogtreecommitdiff
path: root/class/hub
diff options
context:
space:
mode:
Diffstat (limited to 'class/hub')
-rw-r--r--class/hub/usbh_hub.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/class/hub/usbh_hub.c b/class/hub/usbh_hub.c
index 5538de86..b53be6a3 100644
--- a/class/hub/usbh_hub.c
+++ b/class/hub/usbh_hub.c
@@ -71,7 +71,7 @@ static int _usbh_hub_get_hub_descriptor(struct usbh_hub *hub, uint8_t *buffer)
setup->wLength = USB_SIZEOF_HUB_DESC;
ret = usbh_control_transfer(hub->parent, setup, g_hub_buf[hub->bus->busid]);
- if (ret < 0) {
+ if (ret < USB_SIZEOF_HUB_DESC) {
return ret;
}
memcpy(buffer, g_hub_buf[hub->bus->busid], USB_SIZEOF_HUB_DESC);
@@ -93,7 +93,7 @@ static int _usbh_hub_get_hub_ss_descriptor(struct usbh_hub *hub, uint8_t *buffer
setup->wLength = USB_SIZEOF_HUB_SS_DESC;
ret = usbh_control_transfer(hub->parent, setup, g_hub_buf[hub->bus->busid]);
- if (ret < 0) {
+ if (ret < USB_SIZEOF_HUB_SS_DESC) {
return ret;
}
memcpy(buffer, g_hub_buf[hub->bus->busid], USB_SIZEOF_HUB_SS_DESC);
@@ -115,7 +115,7 @@ static int _usbh_hub_get_portstatus(struct usbh_hub *hub, uint8_t port, struct h
setup->wLength = 4;
ret = usbh_control_transfer(hub->parent, setup, g_hub_buf[hub->bus->busid]);
- if (ret < 0) {
+ if (ret < 4) {
return ret;
}
memcpy(port_status, g_hub_buf[hub->bus->busid], 4);
@@ -731,21 +731,21 @@ int usbh_hub_initialize(struct usbh_bus *bus)
bus->hub_mq = usb_osal_mq_create(7);
if (bus->hub_mq == NULL) {
- USB_LOG_ERR("Failed to create hub mq\r\n");
- return -1;
+ return -USB_ERR_NOMEM;
}
bus->hub_sem = usb_osal_sem_create(0);
if (bus->hub_sem == NULL) {
- USB_LOG_ERR("Failed to create hub sem\r\n");
- return -1;
+ usb_osal_mq_delete(bus->hub_mq);
+ return -USB_ERR_NOMEM;
}
snprintf(thread_name, 32, "usbh_hub%u", bus->busid);
bus->hub_thread = usb_osal_thread_create(thread_name, CONFIG_USBHOST_PSC_STACKSIZE, CONFIG_USBHOST_PSC_PRIO, usbh_hub_thread, bus);
if (bus->hub_thread == NULL) {
- USB_LOG_ERR("Failed to create hub thread\r\n");
- return -1;
+ usb_osal_mq_delete(bus->hub_mq);
+ usb_osal_sem_delete(bus->hub_sem);
+ return -USB_ERR_NOMEM;
}
return 0;
}
@@ -759,6 +759,7 @@ int usbh_hub_deinitialize(struct usbh_bus *bus)
usb_osal_mq_send(bus->hub_mq, (uintptr_t)NULL);
usb_osal_sem_take(bus->hub_sem, USB_OSAL_WAITING_FOREVER);
usb_osal_sem_delete(bus->hub_sem);
+ usb_osal_mq_delete(bus->hub_mq);
bus->hub_mq = NULL;
bus->hub_sem = NULL;