Skip to content

[USB Host CDC] Redundant reset of out_xfer in _cdc_close function (AEGHB-1338) #625

@OJZen

Description

@OJZen

Answers checklist.

  • I have read the documentation ESP-IDF Programming Guide and the issue is not addressed there.
  • I have updated my IDF branch (master or release) to the latest version and checked that the issue is present there.
  • I have searched the issue tracker for a similar issue and not found a similar issue.

General issue report

Describe the bug
In the _cdc_close function, the cdc->data.out_xfer is reset (halted and flushed) twice. The first reset appears redundant and may not be necessary.

Code Snippet

// Cancel polling of BULK IN
if (cdc->data.in_xfer) {
ESP_ERROR_CHECK(_cdc_reset_transfer_endpoint(cdc->dev_hdl, cdc->data.in_xfer));
}
ESP_ERROR_CHECK(_cdc_reset_transfer_endpoint(cdc->dev_hdl, cdc->data.out_xfer));
if (cdc->notif.xfer) {
ESP_ERROR_CHECK(_cdc_reset_transfer_endpoint(cdc->dev_hdl, cdc->notif.xfer));
}
if ((cdc->notif.intf_desc != NULL) && cdc->notif.intf_desc != cdc->data.intf_desc) {
ESP_ERROR_CHECK(usb_host_interface_release(p_usbh_cdc_obj->cdc_client_hdl, cdc->dev_hdl, cdc->notif.intf_desc->bInterfaceNumber));
}
if (cdc->data.out_xfer) {
ESP_ERROR_CHECK(_cdc_reset_transfer_endpoint(cdc->dev_hdl, cdc->data.out_xfer));
}
// wait for transfers to complete
vTaskDelay(10 / portTICK_PERIOD_MS);
// Release all interfaces
ESP_ERROR_CHECK(usb_host_interface_release(p_usbh_cdc_obj->cdc_client_hdl, cdc->dev_hdl, cdc->data.intf_desc->bInterfaceNumber));

Expected behavior
The first reset for cdc->data.out_xfer should be removed to avoid unnecessary function calls and potential confusion.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions