diff options
author | Badhri Jagan Sridharan <Badhri@google.com> | 2017-08-10 21:15:42 -0700 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2017-08-18 15:57:16 -0700 |
commit | b46a9c9095bf1652a591149b6febe5e5413a60b3 (patch) | |
tree | 0287b234ec56ef965bcef8188f076460d5dc021f /drivers/staging | |
parent | c749d4d0e4b80cf52b9f916887c5480089cbdd93 (diff) |
staging: typec: tcpm: Select default state based on port type
tcpm_default_state wasn't considering the port type when determining the
default role. This change makes tcpm_default_state to consider port type
as well.
tcpm_default_state would return the following based on the port type:
TYPEC_PORT_UFP - SNK_UNATTACHED
TYPEC_PORT_DFP - SRC_UNATTACHED
TYPEC_PORT_DRP - based on the preferred_role setting
Signed-off-by: Badhri Jagan Sridharan <Badhri@google.com>
[groeck: Reworded description; minor formatting changes]
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging')
-rw-r--r-- | drivers/staging/typec/tcpm.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/drivers/staging/typec/tcpm.c b/drivers/staging/typec/tcpm.c index eb113399f2ab..ac08364e86a6 100644 --- a/drivers/staging/typec/tcpm.c +++ b/drivers/staging/typec/tcpm.c @@ -332,12 +332,17 @@ struct pd_rx_event { static enum tcpm_state tcpm_default_state(struct tcpm_port *port) { - if (port->try_role == TYPEC_SINK) - return SNK_UNATTACHED; - else if (port->try_role == TYPEC_SOURCE) - return SRC_UNATTACHED; - else if (port->tcpc->config->default_role == TYPEC_SINK) + if (port->typec_caps.type == TYPEC_PORT_DRP) { + if (port->try_role == TYPEC_SINK) + return SNK_UNATTACHED; + else if (port->try_role == TYPEC_SOURCE) + return SRC_UNATTACHED; + else if (port->tcpc->config->default_role == TYPEC_SINK) + return SNK_UNATTACHED; + /* Fall through to return SRC_UNATTACHED */ + } else if (port->typec_caps.type == TYPEC_PORT_UFP) { return SNK_UNATTACHED; + } return SRC_UNATTACHED; } |