summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVijayavardhan Vennapusa <vvreddy@codeaurora.org>2017-05-16 14:55:51 +0530
committerGerrit - the friendly Code Review server <code-review@localhost>2017-05-18 02:25:22 -0700
commit0355a024aa005fe9f50e268cada2fd8367e1961b (patch)
tree623b87dba7fd93a400fc173fd9a9bbd2ed95f13c
parent5404e35069576a8cd8203065f60975e34a5f727b (diff)
policy_engine: Don't allow MODE change if no active connection
Currently driver is allowing MODE change even if there is no active cable connection and is waiting for to complete. For this MODE change to complete, driver first sets power role to none to do type C disconnect and then switch to new mode. Here disconnect won't come as there is no active cable connection. Fix this issue by returning error in case there is no active connection. Change-Id: Ie423bd8b61ab7b2624f98c84e8d8e75b6c853b00 Signed-off-by: Vijayavardhan Vennapusa <vvreddy@codeaurora.org>
-rw-r--r--drivers/usb/pd/policy_engine.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/drivers/usb/pd/policy_engine.c b/drivers/usb/pd/policy_engine.c
index 055c6203577a..842556f33a85 100644
--- a/drivers/usb/pd/policy_engine.c
+++ b/drivers/usb/pd/policy_engine.c
@@ -2519,6 +2519,11 @@ static int usbpd_dr_set_property(struct dual_role_phy_instance *dual_role,
case DUAL_ROLE_PROP_MODE:
usbpd_dbg(&pd->dev, "Setting mode to %d\n", *val);
+ if (pd->current_state == PE_UNKNOWN) {
+ usbpd_warn(&pd->dev, "No active connection. Don't allow MODE change\n");
+ return -EAGAIN;
+ }
+
/*
* Forces disconnect on CC and re-establishes connection.
* This does not use PD-based PR/DR swap