Skip to content

Commit 0c388cf

Browse files
Merge branch 'refactor/usb_host_add_func_ret_values_description' into 'master'
Refactor: USB Host add function return values description Closes IDF-10455 See merge request espressif/esp-idf!32106
2 parents ee41fc8 + f7b31de commit 0c388cf

File tree

14 files changed

+674
-213
lines changed

14 files changed

+674
-213
lines changed

components/usb/enum.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1141,7 +1141,7 @@ esp_err_t enum_install(enum_config_t *config, void **client_ret)
11411141
// Initialize ENUM objects
11421142
urb_t *urb = urb_alloc(sizeof(usb_setup_packet_t) + ENUM_CTRL_TRANSFER_MAX_DATA_LEN, 0);
11431143
if (urb == NULL) {
1144-
ret = ESP_ERR_NOT_FINISHED;
1144+
ret = ESP_ERR_NO_MEM;
11451145
goto alloc_err;
11461146
}
11471147

@@ -1164,7 +1164,7 @@ esp_err_t enum_install(enum_config_t *config, void **client_ret)
11641164

11651165
// Enumeration driver is single_threaded
11661166
if (p_enum_driver != NULL) {
1167-
ret = ESP_ERR_NOT_FINISHED;
1167+
ret = ESP_ERR_INVALID_STATE;
11681168
goto err;
11691169
}
11701170
p_enum_driver = enum_drv;

components/usb/ext_hub.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1288,12 +1288,14 @@ esp_err_t ext_hub_new_dev(uint8_t dev_addr)
12881288
// Open device
12891289
ret = usbh_devs_open(dev_addr, &dev_hdl);
12901290
if (ret != ESP_OK) {
1291+
ESP_LOGE(EXT_HUB_TAG, "USBH device opening error: %s", esp_err_to_name(ret));
12911292
return ret;
12921293
}
12931294

12941295
// Get Configuration Descriptor
12951296
ret = usbh_dev_get_config_desc(dev_hdl, &config_desc);
12961297
if (ret != ESP_OK) {
1298+
ESP_LOGE(EXT_HUB_TAG, "Getting config desc error %s", esp_err_to_name(ret));
12971299
goto exit;
12981300
}
12991301

@@ -1307,12 +1309,14 @@ esp_err_t ext_hub_new_dev(uint8_t dev_addr)
13071309

13081310
ret = find_first_intf_desc(config_desc, &hub_config);
13091311
if (ret != ESP_OK) {
1312+
ESP_LOGE(EXT_HUB_TAG, "Finding HUB interface error %s", esp_err_to_name(ret));
13101313
goto exit;
13111314
}
13121315

13131316
// Create External Hub device
13141317
ret = device_alloc(&hub_config, &hub_dev);
13151318
if (ret != ESP_OK) {
1319+
ESP_LOGE(EXT_HUB_TAG, "External HUB device alloc error %s", esp_err_to_name(ret));
13161320
goto exit;
13171321
}
13181322

components/usb/hcd_dwc.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1011,6 +1011,7 @@ esp_err_t hcd_install(const hcd_config_t *config)
10111011
(void *)p_hcd_obj_dmy->port_obj,
10121012
&p_hcd_obj_dmy->isr_hdl);
10131013
if (err_ret != ESP_OK) {
1014+
ESP_LOGE(HCD_DWC_TAG, "Interrupt alloc error: %s", esp_err_to_name(err_ret));
10141015
goto intr_alloc_err;
10151016
}
10161017
HCD_ENTER_CRITICAL();

components/usb/hub.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,7 @@ esp_err_t hub_install(hub_config_t *hub_config, void **client_ret)
479479
};
480480
ret = ext_hub_install(&ext_hub_config);
481481
if (ret != ESP_OK) {
482+
ESP_LOGE(HUB_DRIVER_TAG, "Ext hub install error: %s", esp_err_to_name(ret));
482483
goto err_ext_hub;
483484
}
484485
*client_ret = ext_hub_get_client();
@@ -496,6 +497,7 @@ esp_err_t hub_install(hub_config_t *hub_config, void **client_ret)
496497
hcd_port_handle_t root_port_hdl;
497498
ret = hcd_port_init(HUB_ROOT_PORT_NUM, &port_config, &root_port_hdl);
498499
if (ret != ESP_OK) {
500+
ESP_LOGE(HUB_DRIVER_TAG, "HCD Port init error: %s", esp_err_to_name(ret));
499501
goto err;
500502
}
501503

@@ -598,6 +600,9 @@ esp_err_t hub_port_recycle(usb_device_handle_t parent_dev_hdl, uint8_t parent_po
598600
ext_hub_handle_t ext_hub_hdl = NULL;
599601
ext_hub_get_handle(parent_dev_hdl, &ext_hub_hdl);
600602
ret = ext_hub_port_recycle(ext_hub_hdl, parent_port_num);
603+
if (ret != ESP_OK) {
604+
ESP_LOGE(HUB_DRIVER_TAG, "Ext hub port recycle error: %s", esp_err_to_name(ret));
605+
}
601606
#else
602607
ESP_LOGW(HUB_DRIVER_TAG, "Recycling External Port is not available (External Hub support disabled)");
603608
ret = ESP_ERR_NOT_SUPPORTED;
@@ -626,6 +631,9 @@ esp_err_t hub_port_reset(usb_device_handle_t parent_dev_hdl, uint8_t parent_port
626631
ext_hub_handle_t ext_hub_hdl = NULL;
627632
ext_hub_get_handle(parent_dev_hdl, &ext_hub_hdl);
628633
ret = ext_hub_port_reset(ext_hub_hdl, parent_port_num);
634+
if (ret != ESP_OK) {
635+
ESP_LOGE(HUB_DRIVER_TAG, "Ext hub port reset error: %s", esp_err_to_name(ret));
636+
}
629637
#else
630638
ESP_LOGW(HUB_DRIVER_TAG, "Resetting External Port is not available (External Hub support disabled)");
631639
ret = ESP_ERR_NOT_SUPPORTED;
@@ -647,6 +655,9 @@ esp_err_t hub_port_active(usb_device_handle_t parent_dev_hdl, uint8_t parent_por
647655
ext_hub_handle_t ext_hub_hdl = NULL;
648656
ext_hub_get_handle(parent_dev_hdl, &ext_hub_hdl);
649657
ret = ext_hub_port_active(ext_hub_hdl, parent_port_num);
658+
if (ret != ESP_OK) {
659+
ESP_LOGE(HUB_DRIVER_TAG, "Ext hub port activation error: %s", esp_err_to_name(ret));
660+
}
650661
#else
651662
ESP_LOGW(HUB_DRIVER_TAG, "Activating External Port is not available (External Hub support disabled)");
652663
ret = ESP_ERR_NOT_SUPPORTED;

components/usb/include/usb/usb_helpers.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -129,7 +129,7 @@ typedef void (*print_class_descriptor_cb)(const usb_standard_desc_t *);
129129
/**
130130
* @brief Print device descriptor
131131
*
132-
* @param devc_desc Device descriptor
132+
* @param[in] devc_desc Device descriptor
133133
*/
134134
void usb_print_device_descriptor(const usb_device_desc_t *devc_desc);
135135

@@ -139,17 +139,17 @@ void usb_print_device_descriptor(const usb_device_desc_t *devc_desc);
139139
* - This function prints the full contents of a configuration descriptor (including interface and endpoint descriptors)
140140
* - When a non-standard descriptor is encountered, this function will call the class_specific_cb if it is provided
141141
*
142-
* @param cfg_desc Configuration descriptor
143-
* @param class_specific_cb Class specific descriptor callback. Can be NULL
142+
* @param[in] cfg_desc Configuration descriptor
143+
* @param[in] class_specific_cb Class specific descriptor callback. Can be NULL
144144
*/
145145
void usb_print_config_descriptor(const usb_config_desc_t *cfg_desc, print_class_descriptor_cb class_specific_cb);
146146

147147
/**
148148
* @brief Print a string descriptor
149149
*
150-
* This funciton will only print ASCII characters of the UTF-16 encoded string
150+
* This function will only print ASCII characters of the UTF-16 encoded string
151151
*
152-
* @param str_desc String descriptor
152+
* @param[in] str_desc String descriptor
153153
*/
154154
void usb_print_string_descriptor(const usb_str_desc_t *str_desc);
155155

0 commit comments

Comments
 (0)