summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJett Rink <jettrink@chromium.org>2019-10-03 10:47:05 -0600
committerDenis Brockus <dbrockus@chromium.org>2019-10-11 18:57:43 +0000
commit2056dc60eeb70348795cd680f7de4d3328715fac (patch)
tree2cac73169c5a92f68eaac39cc7fa198343a9caea
parent29b062e276b8d55788cd7157b9b38a584ca4a62f (diff)
downloadchrome-ec-2056dc60eeb70348795cd680f7de4d3328715fac.tar.gz
usbc: check positive condition before error
Since it is possible for the TCPC to give us both a TX complete and have the RX message waiting for us, it makes sense to check the TX complete success case first, and only transition to the error scenario if we get an unexpected RX and we haven't completed the TX BRANCH=none BUG=none TEST=build and passes all tests Change-Id: Ifc5bc52250d25963f2ce6e4ce78f73d9881385e4 Signed-off-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1837996 Tested-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Edward Hill <ecgh@chromium.org>
-rw-r--r--common/usbc/usb_prl_sm.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/common/usbc/usb_prl_sm.c b/common/usbc/usb_prl_sm.c
index 411ec61ad6..5bb8ea1d8a 100644
--- a/common/usbc/usb_prl_sm.c
+++ b/common/usbc/usb_prl_sm.c
@@ -1084,10 +1084,17 @@ static void rch_requesting_chunk_entry(const int port)
static void rch_requesting_chunk_run(const int port)
{
/*
+ * Message Transmitted received from Protocol Layer
+ */
+ if (PDMSG_CHK_FLAG(port, PRL_FLAGS_TX_COMPLETE)) {
+ PDMSG_CLR_FLAG(port, PRL_FLAGS_TX_COMPLETE);
+ set_state_rch(port, RCH_WAITING_CHUNK);
+ }
+ /*
* Transmission Error from Protocol Layer or
* Message Received From Protocol Layer
*/
- if (RCH_CHK_FLAG(port, PRL_FLAGS_MSG_RECEIVED) ||
+ else if (RCH_CHK_FLAG(port, PRL_FLAGS_MSG_RECEIVED) ||
PDMSG_CHK_FLAG(port, PRL_FLAGS_TX_ERROR)) {
/*
* Leave PRL_FLAGS_MSG_RECEIVED flag set. It'll be
@@ -1095,13 +1102,6 @@ static void rch_requesting_chunk_run(const int port)
*/
set_state_rch(port, RCH_REPORT_ERROR);
}
- /*
- * Message Transmitted received from Protocol Layer
- */
- else if (PDMSG_CHK_FLAG(port, PRL_FLAGS_TX_COMPLETE)) {
- PDMSG_CLR_FLAG(port, PRL_FLAGS_TX_COMPLETE);
- set_state_rch(port, RCH_WAITING_CHUNK);
- }
}
/*