From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751660AbdH1RYJ (ORCPT ); Mon, 28 Aug 2017 13:24:09 -0400 Received: from mail-pf0-f175.google.com ([209.85.192.175]:34405 "EHLO mail-pf0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751532AbdH1RYG (ORCPT ); Mon, 28 Aug 2017 13:24:06 -0400 X-Google-Smtp-Source: ADKCNb4Dwln8dvD/IqYjw8TsTalLsJIxG8uWmW5/eHSXpqLA0Bg1/CKzb4FISEOEXCgwQPi0VpW48g== From: Badhri Jagan Sridharan X-Google-Original-From: Badhri Jagan Sridharan To: Greg Kroah-Hartman , Guenter Roeck Cc: devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, Badhri Jagan Sridharan Subject: [PATCH 07/11 v3] staging: typec: tcpm: Consider port_type while determining unattached_state Date: Mon, 28 Aug 2017 10:23:18 -0700 Message-Id: <20170828172322.7166-7-Badhri@google.com> X-Mailer: git-send-email 2.14.1.342.g6490525c54-goog In-Reply-To: <20170828172322.7166-1-Badhri@google.com> References: <20170828172322.7166-1-Badhri@google.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org While performing PORT_RESET, upon receiving the cc disconnect signal from the underlaying tcpc device, TCPM transitions into unattached state. Consider the current type of port while determining the unattached state. In the below logs, although the port_type was set to sink, TCPM transitioned into SRC_UNATTACHED. [ 762.290654] state change SRC_READY -> PORT_RESET [ 762.324531] Setting voltage/current limit 0 mV 0 mA [ 762.327912] polarity 0 [ 762.334864] cc:=0 [ 762.347193] pending state change PORT_RESET -> PORT_RESET_WAIT_OFF @ 100 ms [ 762.347200] VBUS off [ 762.347203] CC1: 2 -> 0, CC2: 0 -> 0 [state PORT_RESET, polarity 0, disconnected] [ 762.347206] state change PORT_RESET -> SRC_UNATTACHED Signed-off-by: Badhri Jagan Sridharan Reviewed-by: Guenter Roeck --- Changelog since previous version: - Only one previous version of the patch was sent. Numbering this V3 instead of V2 to keep the sequence number in sync with the rest of the patches in the patch list. - added Reviewed-by: Guenter Roeck - fixed version/sequence numbers - addressed comment nit drivers/staging/typec/tcpm.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/staging/typec/tcpm.c b/drivers/staging/typec/tcpm.c index 0ae33330a5c7..645f43ee83df 100644 --- a/drivers/staging/typec/tcpm.c +++ b/drivers/staging/typec/tcpm.c @@ -2117,10 +2117,16 @@ static inline enum tcpm_state ready_state(struct tcpm_port *port) static inline enum tcpm_state unattached_state(struct tcpm_port *port) { - if (port->pwr_role == TYPEC_SOURCE) + if (port->port_type == TYPEC_PORT_DRP) { + if (port->pwr_role == TYPEC_SOURCE) + return SRC_UNATTACHED; + else + return SNK_UNATTACHED; + } else if (port->port_type == TYPEC_PORT_DFP) { return SRC_UNATTACHED; - else - return SNK_UNATTACHED; + } + + return SNK_UNATTACHED; } static void tcpm_check_send_discover(struct tcpm_port *port) -- 2.14.1.342.g6490525c54-goog