summaryrefslogtreecommitdiff
path: root/common/host_command.c
diff options
context:
space:
mode:
authorTom Hughes <tomhughes@chromium.org>2019-09-20 10:04:44 -0700
committerCommit Bot <commit-bot@chromium.org>2019-10-02 10:19:57 +0000
commit83d793839479a6f3414dbf51c00536aff65618f3 (patch)
tree41047552e73878fad5ddbc4126d59a52643b041f /common/host_command.c
parent4e692f29e3e5af6b85df472e4c4f936c6f461cb9 (diff)
downloadchrome-ec-83d793839479a6f3414dbf51c00536aff65618f3.tar.gz
host_command: Change host command return value to enum ec_status
If the host command handler callback function returns an int, it's easy to accidentally mix up the enum ec_error_list and enum ec_status types. The host commands always expect an enum ec_status type, so we change the return value to be of that explicit type. Compilation will then fail if you accidentally try to return an enum ec_error_list value. Ran the following commands and then manually fixed up a few remaining instances that were not caught: git grep --name-only 'static int .*(struct host_cmd_handler_args \*args)' |\ xargs sed -i 's#static int \(.*\)(struct host_cmd_handler_args \*args)#\ static enum ec_status \1(struct host_cmd_handler_args \*args)##' git grep --name-only 'int .*(struct host_cmd_handler_args \*args)' |\ xargs sed -i 's#int \(.*\)(struct host_cmd_handler_args \*args)#\ enum ec_status \1(struct host_cmd_handler_args \*args)##' BRANCH=none BUG=chromium:1004831 TEST=make buildall -j Cq-Depend: chrome-internal:1872675 Change-Id: Id93df9387ac53d016a1594dba86c6642babbfd1e Signed-off-by: Tom Hughes <tomhughes@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1816865 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
Diffstat (limited to 'common/host_command.c')
-rw-r--r--common/host_command.c35
1 files changed, 21 insertions, 14 deletions
diff --git a/common/host_command.c b/common/host_command.c
index f4431b3c99..9e14156c6e 100644
--- a/common/host_command.c
+++ b/common/host_command.c
@@ -469,7 +469,8 @@ void host_command_task(void *u)
/* Host commands */
/* TODO(crosbug.com/p/11223): Remove this once the kernel no longer cares */
-static int host_command_proto_version(struct host_cmd_handler_args *args)
+static enum ec_status
+host_command_proto_version(struct host_cmd_handler_args *args)
{
struct ec_response_proto_version *r = args->response;
@@ -482,7 +483,7 @@ DECLARE_HOST_COMMAND(EC_CMD_PROTO_VERSION,
host_command_proto_version,
EC_VER_MASK(0));
-static int host_command_hello(struct host_cmd_handler_args *args)
+static enum ec_status host_command_hello(struct host_cmd_handler_args *args)
{
const struct ec_params_hello *p = args->params;
struct ec_response_hello *r = args->response;
@@ -497,7 +498,7 @@ DECLARE_HOST_COMMAND(EC_CMD_HELLO,
host_command_hello,
EC_VER_MASK(0));
-static int host_command_read_test(struct host_cmd_handler_args *args)
+static enum ec_status host_command_read_test(struct host_cmd_handler_args *args)
{
const struct ec_params_read_test *p = args->params;
struct ec_response_read_test *r = args->response;
@@ -525,7 +526,8 @@ DECLARE_HOST_COMMAND(EC_CMD_READ_TEST,
* Host command to read memory map is not needed on LPC, because LPC can
* directly map the data to the host's memory space.
*/
-static int host_command_read_memmap(struct host_cmd_handler_args *args)
+static enum ec_status
+host_command_read_memmap(struct host_cmd_handler_args *args)
{
const struct ec_params_read_memmap *p = args->params;
@@ -552,7 +554,8 @@ DECLARE_HOST_COMMAND(EC_CMD_READ_MEMMAP,
EC_VER_MASK(0));
#endif
-static int host_command_get_cmd_versions(struct host_cmd_handler_args *args)
+static enum ec_status
+host_command_get_cmd_versions(struct host_cmd_handler_args *args)
{
const struct ec_params_get_cmd_versions *p = args->params;
const struct ec_params_get_cmd_versions_v1 *p_v1 = args->params;
@@ -716,14 +719,15 @@ uint16_t host_command_process(struct host_cmd_handler_args *args)
#ifdef CONFIG_HOST_COMMAND_STATUS
/* Returns current command status (busy or not) */
-static int host_command_get_comms_status(struct host_cmd_handler_args *args)
+static enum ec_status
+host_command_get_comms_status(struct host_cmd_handler_args *args)
{
struct ec_response_get_comms_status *r = args->response;
r->flags = command_pending ? EC_COMMS_STATUS_PROCESSING : 0;
args->response_size = sizeof(*r);
- return EC_SUCCESS;
+ return EC_RES_SUCCESS;
}
DECLARE_HOST_COMMAND(EC_CMD_GET_COMMS_STATUS,
@@ -731,7 +735,8 @@ DECLARE_HOST_COMMAND(EC_CMD_GET_COMMS_STATUS,
EC_VER_MASK(0));
/* Resend the last saved response */
-static int host_command_resend_response(struct host_cmd_handler_args *args)
+static enum ec_status
+host_command_resend_response(struct host_cmd_handler_args *args)
{
/* Handle resending response */
args->result = saved_result;
@@ -739,7 +744,7 @@ static int host_command_resend_response(struct host_cmd_handler_args *args)
saved_result = EC_RES_UNAVAILABLE;
- return EC_SUCCESS;
+ return EC_RES_SUCCESS;
}
DECLARE_HOST_COMMAND(EC_CMD_RESEND_RESPONSE,
@@ -747,20 +752,21 @@ DECLARE_HOST_COMMAND(EC_CMD_RESEND_RESPONSE,
EC_VER_MASK(0));
#endif /* CONFIG_HOST_COMMAND_STATUS */
-
-static int host_command_entering_mode(struct host_cmd_handler_args *args)
+static enum ec_status
+host_command_entering_mode(struct host_cmd_handler_args *args)
{
struct ec_params_entering_mode *param =
(struct ec_params_entering_mode *)args->params;
args->response_size = 0;
g_vboot_mode = param->vboot_mode;
- return EC_SUCCESS;
+ return EC_RES_SUCCESS;
}
DECLARE_HOST_COMMAND(EC_CMD_ENTERING_MODE,
host_command_entering_mode, EC_VER_MASK(0));
/* Returns what we tell it to. */
-static int host_command_test_protocol(struct host_cmd_handler_args *args)
+static enum ec_status
+host_command_test_protocol(struct host_cmd_handler_args *args)
{
const struct ec_params_test_protocol *p = args->params;
struct ec_response_test_protocol *r = args->response;
@@ -777,7 +783,8 @@ DECLARE_HOST_COMMAND(EC_CMD_TEST_PROTOCOL,
EC_VER_MASK(0));
/* Returns supported features. */
-static int host_command_get_features(struct host_cmd_handler_args *args)
+static enum ec_status
+host_command_get_features(struct host_cmd_handler_args *args)
{
struct ec_response_get_features *r = args->response;
args->response_size = sizeof(*r);