diff options
author | Jett Rink <jettrink@chromium.org> | 2019-08-08 12:31:23 -0600 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2019-08-09 21:50:56 +0000 |
commit | 85d086a15e2dca92c573e5d36ef03db6b428a76b (patch) | |
tree | 6518a4221df0290165aeddf81ddcfd0f00829329 /common | |
parent | a34c6b36d254ad7f537976ba5a3b18844c25e1dc (diff) | |
download | chrome-ec-85d086a15e2dca92c573e5d36ef03db6b428a76b.tar.gz |
usb: convert cc1 from int to enum
Refactor code to use proper type for cc1 and cc2 lines.
BRANCH=none
BUG=none
TEST=builds. No functional change.
Change-Id: Id292db8480920e2b191bac9d9ecc2685f61e4ea9
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1744654
Tested-by: Jett Rink <jettrink@chromium.org>
Reviewed-by: Denis Brockus <dbrockus@chromium.org>
Commit-Queue: Jett Rink <jettrink@chromium.org>
Diffstat (limited to 'common')
-rw-r--r-- | common/usb_pd_protocol.c | 18 | ||||
-rw-r--r-- | common/usb_pd_tcpc.c | 5 | ||||
-rw-r--r-- | common/usbc/usb_prl_sm.c | 3 | ||||
-rw-r--r-- | common/usbc/usb_tc_drp_acc_trysrc_sm.c | 32 | ||||
-rw-r--r-- | common/usbc/usbc_task.c | 3 |
5 files changed, 26 insertions, 35 deletions
diff --git a/common/usb_pd_protocol.c b/common/usb_pd_protocol.c index 3f82341d2b..10bf785ac3 100644 --- a/common/usb_pd_protocol.c +++ b/common/usb_pd_protocol.c @@ -690,7 +690,7 @@ static inline void set_state(int port, enum pd_states next_state) if (next_state == PD_STATE_SRC_DISCONNECTED || next_state == PD_STATE_SNK_DISCONNECTED) { #ifdef CONFIG_USBC_PPC - int cc1, cc2; + enum tcpc_cc_voltage_status cc1, cc2; tcpm_get_cc(port, &cc1, &cc2); /* @@ -874,8 +874,7 @@ static int pd_transmit(int port, enum tcpm_transmit_type type, */ sink_can_xmit(port, SINK_TX_NG); } else if (type != TCPC_TX_HARD_RESET) { - int cc1; - int cc2; + enum tcpc_cc_voltage_status cc1, cc2; tcpm_get_cc(port, &cc1, &cc2); if (cc1 == TYPEC_CC_VOLT_RP_1_5 || @@ -924,8 +923,7 @@ static int pd_transmit(int port, enum tcpm_transmit_type type, #ifdef CONFIG_USB_PD_REV30 static void pd_ca_send_pending(int port) { - int cc1; - int cc2; + enum tcpc_cc_voltage_status cc1, cc2; /* Check if a message has been buffered. */ if (!pd[port].ca_buffered) @@ -2485,7 +2483,8 @@ static void pd_partner_port_reset(int port) #endif /* CONFIG_USB_PD_DUAL_ROLE */ #ifdef CONFIG_USB_PD_DUAL_ROLE_AUTO_TOGGLE -static enum pd_states drp_auto_toggle_next_state(int port, int cc1, int cc2) +static enum pd_states drp_auto_toggle_next_state(int port, + enum tcpc_cc_voltage_status cc1, enum tcpc_cc_voltage_status cc2) { enum pd_states next_state; @@ -2617,7 +2616,8 @@ void pd_ping_enable(int port, int enable) /** * Returns the polarity of a Sink. */ -static inline int get_snk_polarity(int cc1, int cc2) +static inline int get_snk_polarity(enum tcpc_cc_voltage_status cc1, + enum tcpc_cc_voltage_status cc2) { /* the following assumes: * TYPEC_CC_VOLT_RP_3_0 > TYPEC_CC_VOLT_RP_1_5 @@ -2823,7 +2823,7 @@ void pd_task(void *u) int port = TASK_ID_TO_PD_PORT(task_get_current()); uint32_t payload[7]; int timeout = 10*MSEC; - int cc1, cc2; + enum tcpc_cc_voltage_status cc1, cc2; int res, incoming_packet = 0; int hard_reset_count = 0; #ifdef CONFIG_USB_PD_DUAL_ROLE @@ -3081,7 +3081,7 @@ void pd_task(void *u) #endif #ifdef CONFIG_USB_PD_DUAL_ROLE if (pd[port].task_state == PD_STATE_SOFT_RESET) { - int cc1, cc2; + enum tcpc_cc_voltage_status cc1, cc2; /* * Set the terminations to match our power diff --git a/common/usb_pd_tcpc.c b/common/usb_pd_tcpc.c index 216793381f..ae8c2746a6 100644 --- a/common/usb_pd_tcpc.c +++ b/common/usb_pd_tcpc.c @@ -1071,7 +1071,8 @@ int tcpc_set_cc(int port, int pull) return EC_SUCCESS; } -int tcpc_get_cc(int port, int *cc1, int *cc2) +int tcpc_get_cc(int port, enum tcpc_cc_voltage_status *cc1, + enum tcpc_cc_voltage_status *cc2) { *cc2 = pd[port].cc_status[1]; *cc1 = pd[port].cc_status[0]; @@ -1317,7 +1318,7 @@ static void tcpc_i2c_write(int port, int reg, int len, uint8_t *payload) static int tcpc_i2c_read(int port, int reg, uint8_t *payload) { - int cc1, cc2; + enum tcpc_cc_voltage_status cc1, cc2; int alert; switch (reg) { diff --git a/common/usbc/usb_prl_sm.c b/common/usbc/usb_prl_sm.c index f013497cc4..a08f662e76 100644 --- a/common/usbc/usb_prl_sm.c +++ b/common/usbc/usb_prl_sm.c @@ -811,8 +811,7 @@ static int prl_tx_snk_pending_entry(int port) static int prl_tx_snk_pending_run(int port) { - int cc1; - int cc2; + enum tcpc_cc_voltage_status cc1, cc2; tcpm_get_cc(port, &cc1, &cc2); if (cc1 == TYPEC_CC_VOLT_RP_3_0 || cc2 == TYPEC_CC_VOLT_RP_3_0) { diff --git a/common/usbc/usb_tc_drp_acc_trysrc_sm.c b/common/usbc/usb_tc_drp_acc_trysrc_sm.c index 8ec2d27d54..810fc5476e 100644 --- a/common/usbc/usb_tc_drp_acc_trysrc_sm.c +++ b/common/usbc/usb_tc_drp_acc_trysrc_sm.c @@ -761,7 +761,7 @@ void pd_prevent_low_power_mode(int port, int prevent) static void sink_power_sub_states(int port) { - int cc1, cc2, cc; + enum tcpc_cc_voltage_status cc1, cc2, cc; enum tcpc_cc_voltage_status new_cc_voltage; tcpm_get_cc(port, &cc1, &cc2); @@ -920,8 +920,7 @@ static int tc_unattached_snk_entry(int port) static int tc_unattached_snk_run(int port) { - int cc1; - int cc2; + enum tcpc_cc_voltage_status cc1, cc2; /* * TODO(b/137498392): Add wait before sampling the CC @@ -978,8 +977,7 @@ static int tc_attach_wait_snk_entry(int port) static int tc_attach_wait_snk_run(int port) { - int cc1; - int cc2; + enum tcpc_cc_voltage_status cc1, cc2; enum pd_cc_states new_cc_state; /* Check for connection */ @@ -1059,8 +1057,7 @@ static int tc_attached_snk(int port, enum sm_signal sig) static int tc_attached_snk_entry(int port) { - int cc1; - int cc2; + enum tcpc_cc_voltage_status cc1, cc2; tc[port].state_id = TC_ATTACHED_SNK; CPRINTS("C%d: %s", port, tc_state_names[tc[port].state_id]); @@ -1143,8 +1140,7 @@ static int tc_unoriented_dbg_acc_src_entry(int port) static int tc_unoriented_dbg_acc_src_run(int port) { - int cc1; - int cc2; + enum tcpc_cc_voltage_status cc1, cc2; /* Check for connection */ tcpm_get_cc(port, &cc1, &cc2); @@ -1253,8 +1249,7 @@ static int tc_unattached_src_entry(int port) static int tc_unattached_src_run(int port) { - int cc1; - int cc2; + enum tcpc_cc_voltage_status cc1, cc2; /* Check for connection */ tcpm_get_cc(port, &cc1, &cc2); @@ -1303,8 +1298,7 @@ static int tc_attach_wait_src_entry(int port) static int tc_attach_wait_src_run(int port) { - int cc1; - int cc2; + enum tcpc_cc_voltage_status cc1, cc2; enum pd_cc_states new_cc_state; /* Check for connection */ @@ -1371,8 +1365,7 @@ static int tc_attached_src(int port, enum sm_signal sig) static int tc_attached_src_entry(int port) { - int cc1; - int cc2; + enum tcpc_cc_voltage_status cc1, cc2; tc[port].state_id = TC_ATTACHED_SRC; CPRINTS("C%d: %s", port, tc_state_names[tc[port].state_id]); @@ -1421,8 +1414,7 @@ static int tc_attached_src_entry(int port) static int tc_attached_src_run(int port) { - int cc1; - int cc2; + enum tcpc_cc_voltage_status cc1, cc2; enum pd_cc_states new_cc_state; /* Check for connection */ @@ -1508,8 +1500,7 @@ static int tc_try_src_entry(int port) static int tc_try_src_run(int port) { - int cc1; - int cc2; + enum tcpc_cc_voltage_status cc1, cc2; enum pd_cc_states new_cc_state; /* Check for connection */ @@ -1582,8 +1573,7 @@ static int tc_try_wait_snk_entry(int port) static int tc_try_wait_snk_run(int port) { - int cc1; - int cc2; + enum tcpc_cc_voltage_status cc1, cc2; enum pd_cc_states new_cc_state; /* Check for connection */ diff --git a/common/usbc/usbc_task.c b/common/usbc/usbc_task.c index 7ff8bbf44f..b5b94c126a 100644 --- a/common/usbc/usbc_task.c +++ b/common/usbc/usbc_task.c @@ -129,7 +129,8 @@ enum typec_state_id get_typec_state_id(int port) * DTS USB-C @ 3 A Rp3A0 RpUSB */ -inline enum pd_cc_polarity_type get_snk_polarity(int cc1, int cc2) +enum pd_cc_polarity_type get_snk_polarity(enum tcpc_cc_voltage_status cc1, + enum tcpc_cc_voltage_status cc2) { /* the following assumes: * TYPEC_CC_VOLT_RP_3_0 > TYPEC_CC_VOLT_RP_1_5 |