Merge "PD: policy_engine: Add timeout for mode change through sysfs"
This commit is contained in:
commit
8bb96fd0d3
1 changed files with 8 additions and 1 deletions
|
@ -2552,6 +2552,7 @@ static int usbpd_dr_set_property(struct dual_role_phy_instance *dual_role,
|
|||
{
|
||||
struct usbpd *pd = dual_role_get_drvdata(dual_role);
|
||||
bool do_swap = false;
|
||||
int wait_count = 5;
|
||||
|
||||
if (!pd)
|
||||
return -ENODEV;
|
||||
|
@ -2578,9 +2579,15 @@ static int usbpd_dr_set_property(struct dual_role_phy_instance *dual_role,
|
|||
set_power_role(pd, PR_NONE);
|
||||
|
||||
/* wait until it takes effect */
|
||||
while (pd->forced_pr != POWER_SUPPLY_TYPEC_PR_NONE)
|
||||
while (pd->forced_pr != POWER_SUPPLY_TYPEC_PR_NONE &&
|
||||
--wait_count)
|
||||
msleep(20);
|
||||
|
||||
if (!wait_count) {
|
||||
usbpd_err(&pd->dev, "setting mode timed out\n");
|
||||
return -ETIMEDOUT;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case DUAL_ROLE_PROP_DR:
|
||||
|
|
Loading…
Add table
Reference in a new issue