Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1709240

[PATCH 4/7] staging: typec: tcpm: Select default state based on port type

From Guenter Roeck <linux@roeck-us.net>
Newsgroups linux.kernel
Subject [PATCH 4/7] staging: typec: tcpm: Select default state based on port type
Date 2017-08-11 06:20 +0200
Message-ID <ud9At-782-11@gated-at.bofh.it> (permalink)
References <ud9At-782-5@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


From: Badhri Jagan Sridharan <Badhri@google.com>

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>
---
 drivers/staging/typec/tcpm.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/typec/tcpm.c b/drivers/staging/typec/tcpm.c
index e7873286b5ea..cf498c68c4af 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;
 }
 
-- 
2.7.4

Back to linux.kernel | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

[PATCH 1/7] staging: typec: tcpm: Constify alternate modes Guenter Roeck <linux@roeck-us.net> - 2017-08-11 06:20 +0200
  [PATCH 5/7] staging: typec: tcpm: Add timeout when waiting for role swap completion Guenter Roeck <linux@roeck-us.net> - 2017-08-11 06:20 +0200
  [PATCH 7/7] staging: typec: tcpm: Check cc status before entering SRC_TRY_DEBOUCE Guenter Roeck <linux@roeck-us.net> - 2017-08-11 06:20 +0200
  [PATCH 3/7] staging: typec: tcpm: Set default state after error recovery based on port type Guenter Roeck <linux@roeck-us.net> - 2017-08-11 06:20 +0200
  [PATCH 4/7] staging: typec: tcpm: Select default state based on port type Guenter Roeck <linux@roeck-us.net> - 2017-08-11 06:20 +0200

csiph-web