From cb51a640f4bf6dc36e263a89b3e5b6a16f0643cc Mon Sep 17 00:00:00 2001 From: Kyle Tso Date: Thu, 13 Jun 2024 16:54:37 +0800 Subject: [PATCH] usb: Log for retry on role switch Add a log for the retry. Also define the sleep time in the header file. Bug: 341996696 Change-Id: Ib3cc0c6ad576e7cda26b7f50cdc61d52e6349c78 Signed-off-by: Kyle Tso (cherry picked from commit d17fdff5f81cff76adaa75d50f26318be8048123) --- usb/usb/Usb.cpp | 3 ++- usb/usb/Usb.h | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/usb/usb/Usb.cpp b/usb/usb/Usb.cpp index da7eb423..2c42b116 100644 --- a/usb/usb/Usb.cpp +++ b/usb/usb/Usb.cpp @@ -603,7 +603,8 @@ ScopedAStatus Usb::switchRole(const string& in_portName, const PortRole& in_role if (fp != NULL) { int ret = fputs(convertRoletoString(in_role).c_str(), fp); if (ret == EAGAIN) { - std::this_thread::sleep_for(std::chrono::milliseconds(700)); + ALOGI("role switch busy, retry in %d ms", ROLE_SWAP_RETRY_MS); + std::this_thread::sleep_for(std::chrono::milliseconds(ROLE_SWAP_RETRY_MS)); ret = fputs(convertRoletoString(in_role).c_str(), fp); } fclose(fp); diff --git a/usb/usb/Usb.h b/usb/usb/Usb.h index 779e7254..d6ed72e9 100644 --- a/usb/usb/Usb.h +++ b/usb/usb/Usb.h @@ -56,6 +56,8 @@ constexpr char kGadgetName[] = "11210000.dwc3"; #define VBUS_PATH NEW_UDC_PATH "dwc3_exynos_otg_b_sess" #define USB_DATA_PATH NEW_UDC_PATH "usb_data_enabled" +#define ROLE_SWAP_RETRY_MS 700 + struct Usb : public BnUsb { Usb();