diff --git a/components/usb/include/usb/usb_host.h b/components/usb/include/usb/usb_host.h index 0524674822..1a4fedf955 100644 --- a/components/usb/include/usb/usb_host.h +++ b/components/usb/include/usb/usb_host.h @@ -323,9 +323,8 @@ esp_err_t usb_host_device_open(usb_host_client_handle_t client_hdl, uint8_t dev_ * @return * - ESP_OK: Device closed successfully * - ESP_ERR_INVALID_ARG: Invalid argument - * - ESP_ERR_NOT_FOUND: Device address not found among opened devices - * - ESP_ERR_INVALID_STATE: The client never opened the device, or the client has not released - * all the interfaces from the device + * - ESP_ERR_NOT_FOUND: The client never opened the device (the device address not found among opened devices) + * - ESP_ERR_INVALID_STATE: The client has not released all interfaces from the device */ esp_err_t usb_host_device_close(usb_host_client_handle_t client_hdl, usb_device_handle_t dev_hdl); diff --git a/components/usb/usb_host.c b/components/usb/usb_host.c index cc8a4dc83b..a402d740a4 100644 --- a/components/usb/usb_host.c +++ b/components/usb/usb_host.c @@ -1012,10 +1012,9 @@ esp_err_t usb_host_device_close(usb_host_client_handle_t client_hdl, usb_device_ HOST_ENTER_CRITICAL(); uint8_t dev_addr; ESP_ERROR_CHECK(usbh_dev_get_addr(dev_hdl, &dev_addr)); - HOST_CHECK_FROM_CRIT(_check_client_opened_device(client_obj, dev_addr), ESP_ERR_NOT_FOUND); if (!_check_client_opened_device(client_obj, dev_addr)) { // Client never opened this device - ret = ESP_ERR_INVALID_STATE; + ret = ESP_ERR_NOT_FOUND; HOST_EXIT_CRITICAL(); goto exit; }