MLK-16013-29 staging: typec: tcpm: Don't reset message id after soft reset
authorLi Jun <jun.li@nxp.com>
Fri, 28 Jul 2017 08:55:33 +0000 (16:55 +0800)
committerNitin Garg <nitin.garg@nxp.com>
Mon, 19 Mar 2018 20:36:21 +0000 (15:36 -0500)
If the power source sent soft reset and the other end accepted, we should
not reset the message id as it was already updated by pd_transmit when
handling the soft reset.

Reviewed-by: Peter Chen <peter.chen@nxp.com>
Signed-off-by: Li Jun <jun.li@nxp.com>
drivers/staging/typec/tcpm.c

index 07241e5..9ec07ce 100644 (file)
@@ -1423,11 +1423,17 @@ static void tcpm_pd_ctrl_request(struct tcpm_port *port,
                        tcpm_set_state(port, SNK_TRANSITION_SINK, 0);
                        break;
                case SOFT_RESET_SEND:
-                       port->message_id = 0;
-                       if (port->pwr_role == TYPEC_SOURCE)
+                       /*
+                        * After reset data sent, the msg id is updated
+                        * by pd_transmit(0+1), now the other end gives
+                        * an accept so we can go on with msg id 1.
+                        */
+                       if (port->pwr_role == TYPEC_SOURCE) {
                                next_state = SRC_SEND_CAPABILITIES;
-                       else
+                       } else {
+                               port->message_id = 0;
                                next_state = SNK_WAIT_CAPABILITIES;
+                       }
                        tcpm_set_state(port, next_state, 0);
                        break;
                case DR_SWAP_SEND: