summaryrefslogtreecommitdiff
path: root/include/host_command.h
diff options
context:
space:
mode:
authorJeff Andersen <jeffandersen@google.com>2017-05-23 17:12:25 -0700
committerchrome-bot <chrome-bot@chromium.org>2017-05-25 04:27:41 -0700
commitcf81f80c4f1fe9294848d56c75e68699e85d8e03 (patch)
tree0d459169860b2e0a3eff13b5147cecda16388e54 /include/host_command.h
parent4fd6f23101d1f7aed89568e5f4cacb99b5ae4710 (diff)
downloadchrome-ec-cf81f80c4f1fe9294848d56c75e68699e85d8e03.tar.gz
Enable two-byte responses from host command handlers.
Previously, result codes were being stored as `enum ec_status` values. The compiler was forcing this value to only be one byte large, since that's all that was necessary to represent all the values of that enum. This change fixes this bug by switching result code variable types from `enum ec_status` to `uint16_t`. BRANCH=none BUG=none TEST=make buildall -j Change-Id: Iacdca51dc6c1de677d2fbb59ad6dd2572d21ea7f Reviewed-on: https://chromium-review.googlesource.com/513609 Commit-Ready: Jeff Andersen <jeffandersen@google.com> Tested-by: Jeff Andersen <jeffandersen@google.com> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
Diffstat (limited to 'include/host_command.h')
-rw-r--r--include/host_command.h21
1 files changed, 17 insertions, 4 deletions
diff --git a/include/host_command.h b/include/host_command.h
index 02c9b07915..50466dc61d 100644
--- a/include/host_command.h
+++ b/include/host_command.h
@@ -48,8 +48,13 @@ struct host_cmd_handler_args {
* command execution is complete. The driver may still override this
* when sending the response back to the host if it detects an error
* in the response or in its own operation.
+ *
+ * Note that while this holds an ec_status enum, we are intentionally
+ * representing this field as a uint16_t, to prevent issues related to
+ * compiler optimizations affecting the range of values representable
+ * by this field.
*/
- enum ec_status result;
+ uint16_t result;
};
/* Args for host packet handler */
@@ -95,8 +100,13 @@ struct host_packet {
* Error from driver; if this is non-zero, host command handler will
* return a properly formatted error response packet rather than
* calling a command handler.
+ *
+ * Note that while this holds an ec_status enum, we are intentionally
+ * representing this field as a uint16_t, to prevent issues related to
+ * compiler optimizations affecting the range of values representable
+ * by this field.
*/
- enum ec_status driver_result;
+ uint16_t driver_result;
};
/* Host command */
@@ -127,9 +137,12 @@ uint8_t *host_get_memmap(int offset);
* Process a host command and return its response
*
* @param args Command handler args
- * @return resulting status
+ * @return resulting status. Note that while this returns an ec_status enum, we
+ * are intentionally specifying the return type as a uint16_t, to prevent issues
+ * related to compiler optimizations affecting the range of values returnable
+ * from this function.
*/
-enum ec_status host_command_process(struct host_cmd_handler_args *args);
+uint16_t host_command_process(struct host_cmd_handler_args *args);
#ifdef CONFIG_HOSTCMD_EVENTS
/**