From 3fd17b8be8f92e521c223c3e0e42df5170b06453 Mon Sep 17 00:00:00 2001 From: Roman Leonov Date: Thu, 15 May 2025 11:10:23 +0200 Subject: [PATCH] refactor(hub): Applied new ext_hub api, refactor func names --- components/usb/hub.c | 16 +++++++++------- components/usb/private_include/hub.h | 4 ++-- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/components/usb/hub.c b/components/usb/hub.c index 7afb5873c8..dccd92ba44 100644 --- a/components/usb/hub.c +++ b/components/usb/hub.c @@ -771,7 +771,7 @@ esp_err_t hub_port_disable(usb_device_handle_t parent_dev_hdl, uint8_t parent_po return ret; } -esp_err_t hub_notify_new_dev(uint8_t dev_addr) +esp_err_t hub_dev_new(uint8_t dev_addr) { HUB_DRIVER_ENTER_CRITICAL(); HUB_DRIVER_CHECK_FROM_CRIT(p_hub_driver_obj != NULL, ESP_ERR_INVALID_STATE); @@ -794,15 +794,15 @@ esp_err_t hub_notify_new_dev(uint8_t dev_addr) } } // Close device - usbh_dev_close(dev_hdl); + ESP_ERROR_CHECK(usbh_dev_close(dev_hdl)); } - // Logic should not stop the flow, so no error to return - ret = ESP_OK; + // Nothing to do, while Hubs support is not enabled + ret = ESP_ERR_NOT_SUPPORTED; #endif // ENABLE_USB_HUBS return ret; } -esp_err_t hub_notify_dev_gone(uint8_t dev_addr) +esp_err_t hub_dev_gone(uint8_t dev_addr) { HUB_DRIVER_ENTER_CRITICAL(); HUB_DRIVER_CHECK_FROM_CRIT(p_hub_driver_obj != NULL, ESP_ERR_INVALID_STATE); @@ -813,7 +813,7 @@ esp_err_t hub_notify_dev_gone(uint8_t dev_addr) ret = ext_hub_dev_gone(dev_addr); #else // Nothing to do, while Hubs support is not enabled - ret = ESP_OK; + ret = ESP_ERR_NOT_SUPPORTED; #endif // ENABLE_USB_HUBS return ret; } @@ -825,7 +825,9 @@ esp_err_t hub_notify_all_free(void) HUB_DRIVER_CHECK_FROM_CRIT(p_hub_driver_obj != NULL, ESP_ERR_INVALID_STATE); HUB_DRIVER_EXIT_CRITICAL(); - return ext_hub_all_free(); + ext_hub_mark_all_free(); + + return ESP_OK; } #endif // ENABLE_USB_HUBS diff --git a/components/usb/private_include/hub.h b/components/usb/private_include/hub.h index 60ee825917..e47e11c189 100644 --- a/components/usb/private_include/hub.h +++ b/components/usb/private_include/hub.h @@ -206,7 +206,7 @@ esp_err_t hub_port_disable(usb_device_handle_t parent_dev_hdl, uint8_t parent_po * - ESP_OK: New device added successfully * - ESP_ERR_INVALID_STATE: Hub driver is not in a correct state */ -esp_err_t hub_notify_new_dev(uint8_t dev_addr); +esp_err_t hub_dev_new(uint8_t dev_addr); /** * @brief Notify Hub driver that device has been removed @@ -222,7 +222,7 @@ esp_err_t hub_notify_new_dev(uint8_t dev_addr); * - ESP_OK: A device removed successfully * - ESP_ERR_INVALID_STATE: Hub driver is not in a correct state */ -esp_err_t hub_notify_dev_gone(uint8_t dev_addr); +esp_err_t hub_dev_gone(uint8_t dev_addr); #if ENABLE_USB_HUBS /**