usb: Add retry on role switch
Bug: 341996696 Change-Id: I8caa65288af1588d24fea4aa6c5768d45d69bbd5 Signed-off-by: Kyle Tso <kyletso@google.com> (cherry picked from commit ef5856a4474002cc35a51377adffddd4cb239796)
This commit is contained in:
parent
9634ba0f84
commit
744c86c49a
1 changed files with 4 additions and 0 deletions
|
@ -593,6 +593,10 @@ ScopedAStatus Usb::switchRole(const string& in_portName, const PortRole& in_role
|
||||||
fp = fopen(filename.c_str(), "w");
|
fp = fopen(filename.c_str(), "w");
|
||||||
if (fp != NULL) {
|
if (fp != NULL) {
|
||||||
int ret = fputs(convertRoletoString(in_role).c_str(), fp);
|
int ret = fputs(convertRoletoString(in_role).c_str(), fp);
|
||||||
|
if (ret == EAGAIN) {
|
||||||
|
std::this_thread::sleep_for(std::chrono::milliseconds(700));
|
||||||
|
ret = fputs(convertRoletoString(in_role).c_str(), fp);
|
||||||
|
}
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
if ((ret != EOF) && ReadFileToString(filename, &written)) {
|
if ((ret != EOF) && ReadFileToString(filename, &written)) {
|
||||||
written = Trim(written);
|
written = Trim(written);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue