summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVic Yang <victoryang@chromium.org>2014-08-18 13:08:43 -0700
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2014-08-28 04:24:09 +0000
commit2fd4b9c5719506793830f8b601bfc893edae1b03 (patch)
tree0daeb550cee32030bcaa649e3e047a6e4882d2e4
parent251f3b0f0beb66cbdd37b7e04828689c3a5b9a25 (diff)
downloadchrome-ec-2fd4b9c5719506793830f8b601bfc893edae1b03.tar.gz
pd: ensure names of PD states are up-to-date
As we add more PD states, it's easy to forget to update the names of PD states. This doesn't break any PD functionality so would be hard to discover. However, it can easily confuse us when we are debugging. Add a compile-time assertion to make sure it's updated. BUG=None TEST=Remove one names and check build fails. BRANCH=None Change-Id: I8b503e361b3418835cdf510dd39481eb7d998035 Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/212885 Reviewed-by: Todd Broch <tbroch@chromium.org> Reviewed-by: Alec Berg <alecaberg@chromium.org>
-rw-r--r--common/usb_pd_protocol.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/common/usb_pd_protocol.c b/common/usb_pd_protocol.c
index 0bf158c790..a8c22d9c69 100644
--- a/common/usb_pd_protocol.c
+++ b/common/usb_pd_protocol.c
@@ -170,6 +170,9 @@ enum pd_states {
PD_STATE_SOFT_RESET,
PD_STATE_HARD_RESET,
PD_STATE_BIST,
+
+ /* Number of states. Not an actual state. */
+ PD_STATE_COUNT,
};
enum vdm_states {
@@ -1380,6 +1383,8 @@ void pd_task(void)
send_bist_cmd(port);
bist_mode_2_rx(port);
break;
+ default:
+ break;
}
pd[port].last_state = this_state;
@@ -1707,6 +1712,7 @@ static int command_pd(int argc, char **argv)
"SRC_ACCEPTED", "SRC_TRANSITION", "SRC_READY",
"SOFT_RESET", "HARD_RESET", "BIST",
};
+ BUILD_ASSERT(ARRAY_SIZE(state_names) == PD_STATE_COUNT);
ccprintf("Port C%d, %s - Role: %s Polarity: CC%d State: %s\n",
port, pd_comm_enabled ? "Enabled" : "Disabled",
pd[port].role == PD_ROLE_SOURCE ? "SRC" : "SNK",