fix(usb_host): Fix return code and description

Changed error code from ESP_ERR_INVALID_STATE to ESP_ERR_NOT_FOUND
when the client never opened the device.
Updated function documentation to correctly reflect return values.
This commit is contained in:
igor.masar
2025-03-25 23:00:56 +01:00
parent a40a50998e
commit 5609df4096
2 changed files with 3 additions and 4 deletions

View File

@ -323,9 +323,8 @@ esp_err_t usb_host_device_open(usb_host_client_handle_t client_hdl, uint8_t dev_
* @return * @return
* - ESP_OK: Device closed successfully * - ESP_OK: Device closed successfully
* - ESP_ERR_INVALID_ARG: Invalid argument * - ESP_ERR_INVALID_ARG: Invalid argument
* - ESP_ERR_NOT_FOUND: Device address not found among opened devices * - ESP_ERR_NOT_FOUND: The client never opened the device (the device address not found among opened devices)
* - ESP_ERR_INVALID_STATE: The client never opened the device, or the client has not released * - ESP_ERR_INVALID_STATE: The client has not released all interfaces from the device
* all the interfaces from the device
*/ */
esp_err_t usb_host_device_close(usb_host_client_handle_t client_hdl, usb_device_handle_t dev_hdl); esp_err_t usb_host_device_close(usb_host_client_handle_t client_hdl, usb_device_handle_t dev_hdl);

View File

@ -1010,7 +1010,7 @@ esp_err_t usb_host_device_close(usb_host_client_handle_t client_hdl, usb_device_
ESP_ERROR_CHECK(usbh_dev_get_addr(dev_hdl, &dev_addr)); ESP_ERROR_CHECK(usbh_dev_get_addr(dev_hdl, &dev_addr));
if (!_check_client_opened_device(client_obj, dev_addr)) { if (!_check_client_opened_device(client_obj, dev_addr)) {
// Client never opened this device // Client never opened this device
ret = ESP_ERR_INVALID_STATE; ret = ESP_ERR_NOT_FOUND;
HOST_EXIT_CRITICAL(); HOST_EXIT_CRITICAL();
goto exit; goto exit;
} }