summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Hughes <tomhughes@chromium.org>2019-11-06 16:50:54 -0800
committerCommit Bot <commit-bot@chromium.org>2019-11-08 20:12:48 +0000
commit129c26685df2a045069cabf8e60fce5ba679e8c5 (patch)
tree2db692072bedb009ecbc4b25d77d05b93069d80a
parentdaee93dd1e7f722a249db0fdf124d5157744f693 (diff)
downloadchrome-ec-129c26685df2a045069cabf8e60fce5ba679e8c5.tar.gz
ec_commands: Force enum to be at least 16 bits
If the values in the enum can fit in a byte, the compiler can optimize the size of the enum to a byte. However, our protocol requires 16 bits, so define a max enum value that forces at least 16 bits. BRANCH=none BUG=b:144056522 TEST=make buildall -j Change-Id: I119d990f2775d8b970ec0ec15df1e451fc5dc45d Signed-off-by: Tom Hughes <tomhughes@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1902679 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Commit-Queue: Jett Rink <jettrink@chromium.org>
-rw-r--r--include/ec_commands.h8
1 files changed, 5 insertions, 3 deletions
diff --git a/include/ec_commands.h b/include/ec_commands.h
index 50b23f6ef3..29278ddebe 100644
--- a/include/ec_commands.h
+++ b/include/ec_commands.h
@@ -536,8 +536,7 @@ extern "C" {
(EC_LPC_STATUS_FROM_HOST | EC_LPC_STATUS_PROCESSING)
/*
- * Host command response codes (16-bit). Note that response codes should be
- * stored in a uint16_t rather than directly in a value of this type.
+ * Host command response codes (16-bit).
*/
enum ec_status {
EC_RES_SUCCESS = 0,
@@ -561,7 +560,10 @@ enum ec_status {
EC_RES_INVALID_HEADER_CRC = 18, /* Header CRC invalid */
EC_RES_INVALID_DATA_CRC = 19, /* Data CRC invalid */
EC_RES_DUP_UNAVAILABLE = 20, /* Can't resend response */
-};
+
+ EC_RES_MAX = UINT16_MAX /**< Force enum to be 16 bits */
+} __packed;
+BUILD_ASSERT(sizeof(enum ec_status) == sizeof(uint16_t));
/*
* Host event codes. Note these are 1-based, not 0-based, because ACPI query