Merge "PD: policy_engine: Add timeout for mode change through sysfs"

This commit is contained in:
Linux Build Service Account 2017-06-09 02:45:17 -07:00 committed by Gerrit - the friendly Code Review server
commit 8bb96fd0d3

View file

@ -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: