diff options
author | Nicolas Boichat <drinkcat@google.com> | 2016-12-02 12:26:24 +0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2016-12-14 06:02:53 -0800 |
commit | a573d17be93b52e6b3cb0ab7bf374199091752f4 (patch) | |
tree | e1fec25b5629577f5358678a7ed16eb330411796 | |
parent | 224466d3ac6f347cf17c224ef1e0114bbc5e4631 (diff) | |
download | chrome-ec-a573d17be93b52e6b3cb0ab7bf374199091752f4.tar.gz |
usb_pd_protocol: Rename PD_FLAGS_DATA_SWAPPED to _CHECK_IDENTITY
Rename the variable to actually tell us what it does (it sends a
Discover Identity command), instead of littering the code with
comments explaining why we set DATA_SWAPPED when the data roles
have not really been swapped.
BRANCH=none
BUG=chromium:644663
TEST=make buildall -j
Change-Id: Idbad38e48a55d6518ef82b32a4d96fee65264aae
Reviewed-on: https://chromium-review.googlesource.com/415696
Commit-Ready: Nicolas Boichat <drinkcat@chromium.org>
Tested-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
-rw-r--r-- | common/usb_pd_protocol.c | 24 | ||||
-rw-r--r-- | include/usb_pd.h | 4 |
2 files changed, 10 insertions, 18 deletions
diff --git a/common/usb_pd_protocol.c b/common/usb_pd_protocol.c index e50bc7f734..1e9c4192ae 100644 --- a/common/usb_pd_protocol.c +++ b/common/usb_pd_protocol.c @@ -884,7 +884,7 @@ static void pd_set_data_role(int port, int role) static void pd_dr_swap(int port) { pd_set_data_role(port, !pd[port].data_role); - pd[port].flags |= PD_FLAGS_DATA_SWAPPED; + pd[port].flags |= PD_FLAGS_CHECK_IDENTITY; } static void handle_ctrl_request(int port, uint16_t head, @@ -1897,11 +1897,7 @@ void pd_task(void) case PD_STATE_SRC_STARTUP: /* Wait for power source to enable */ if (pd[port].last_state != pd[port].task_state) { - /* - * fake set data role swapped flag so we send - * discover identity when we enter SRC_READY - */ - pd[port].flags |= PD_FLAGS_DATA_SWAPPED; + pd[port].flags |= PD_FLAGS_CHECK_IDENTITY; /* reset various counters */ caps_count = 0; pd[port].msg_id = 0; @@ -2059,12 +2055,12 @@ void pd_task(void) /* Send discovery SVDMs last */ if (pd[port].data_role == PD_ROLE_DFP && - (pd[port].flags & PD_FLAGS_DATA_SWAPPED)) { + (pd[port].flags & PD_FLAGS_CHECK_IDENTITY)) { #ifndef CONFIG_USB_PD_SIMPLE_DFP pd_send_vdm(port, USB_SID_PD, CMD_DISCOVER_IDENT, NULL, 0); #endif - pd[port].flags &= ~PD_FLAGS_DATA_SWAPPED; + pd[port].flags &= ~PD_FLAGS_CHECK_IDENTITY; break; } @@ -2320,13 +2316,9 @@ void pd_task(void) /* DFP is attached */ if (new_cc_state == PD_CC_DFP_ATTACHED) { - /* - * fake set data role swapped flag so we send - * discover identity when we enter SRC_READY - */ pd[port].flags |= PD_FLAGS_CHECK_PR_ROLE | PD_FLAGS_CHECK_DR_ROLE | - PD_FLAGS_DATA_SWAPPED; + PD_FLAGS_CHECK_IDENTITY; set_state(port, PD_STATE_SNK_DISCOVERY); timeout = 10*MSEC; hook_call_deferred( @@ -2362,7 +2354,7 @@ defined(CONFIG_CASE_CLOSED_DEBUG_EXTERNAL) break; case PD_STATE_SNK_HARD_RESET_RECOVER: if (pd[port].last_state != pd[port].task_state) - pd[port].flags |= PD_FLAGS_DATA_SWAPPED; + pd[port].flags |= PD_FLAGS_CHECK_IDENTITY; #ifdef CONFIG_USB_PD_VBUS_DETECT_NONE /* * Can't measure vbus state so this is the maximum @@ -2544,10 +2536,10 @@ defined(CONFIG_CASE_CLOSED_DEBUG_EXTERNAL) /* If DFP, send discovery SVDMs */ if (pd[port].data_role == PD_ROLE_DFP && - (pd[port].flags & PD_FLAGS_DATA_SWAPPED)) { + (pd[port].flags & PD_FLAGS_CHECK_IDENTITY)) { pd_send_vdm(port, USB_SID_PD, CMD_DISCOVER_IDENT, NULL, 0); - pd[port].flags &= ~PD_FLAGS_DATA_SWAPPED; + pd[port].flags &= ~PD_FLAGS_CHECK_IDENTITY; break; } diff --git a/include/usb_pd.h b/include/usb_pd.h index 10b148af68..e322fed381 100644 --- a/include/usb_pd.h +++ b/include/usb_pd.h @@ -695,7 +695,7 @@ enum pd_states { #define PD_FLAGS_PING_ENABLED (1 << 0) /* SRC_READY pings enabled */ #define PD_FLAGS_PARTNER_DR_POWER (1 << 1) /* port partner is dualrole power */ #define PD_FLAGS_PARTNER_DR_DATA (1 << 2) /* port partner is dualrole data */ -#define PD_FLAGS_DATA_SWAPPED (1 << 3) /* data swap complete */ +#define PD_FLAGS_CHECK_IDENTITY (1 << 3) /* discover identity in READY */ #define PD_FLAGS_SNK_CAP_RECVD (1 << 4) /* sink capabilities received */ #define PD_FLAGS_TCPC_DRP_TOGGLE (1 << 5) /* TCPC-controlled DRP toggling */ #define PD_FLAGS_EXPLICIT_CONTRACT (1 << 6) /* explicit pwr contract in place */ @@ -711,7 +711,7 @@ enum pd_states { /* Flags to clear on a disconnect */ #define PD_FLAGS_RESET_ON_DISCONNECT_MASK (PD_FLAGS_PARTNER_DR_POWER | \ PD_FLAGS_PARTNER_DR_DATA | \ - PD_FLAGS_DATA_SWAPPED | \ + PD_FLAGS_CHECK_IDENTITY | \ PD_FLAGS_SNK_CAP_RECVD | \ PD_FLAGS_TCPC_DRP_TOGGLE | \ PD_FLAGS_EXPLICIT_CONTRACT | \ |