From 83d793839479a6f3414dbf51c00536aff65618f3 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Fri, 20 Sep 2019 10:04:44 -0700 Subject: 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 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1816865 Reviewed-by: Daisuke Nojiri Reviewed-by: Jack Rosenthal --- common/charge_manager.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'common/charge_manager.c') diff --git a/common/charge_manager.c b/common/charge_manager.c index 4c56a21afc..176781234f 100644 --- a/common/charge_manager.c +++ b/common/charge_manager.c @@ -1196,7 +1196,7 @@ int charge_manager_get_source_pdo(const uint32_t **src_pdo, const int port) #endif /* CONFIG_USB_PD_MAX_SINGLE_SOURCE_CURRENT */ #ifndef TEST_BUILD -static int hc_pd_power_info(struct host_cmd_handler_args *args) +static enum ec_status hc_pd_power_info(struct host_cmd_handler_args *args) { const struct ec_params_usb_pd_power_info *p = args->params; struct ec_response_usb_pd_power_info *r = args->response; @@ -1219,7 +1219,7 @@ DECLARE_HOST_COMMAND(EC_CMD_USB_PD_POWER_INFO, EC_VER_MASK(0)); #endif /* TEST_BUILD */ -static int hc_charge_port_count(struct host_cmd_handler_args *args) +static enum ec_status hc_charge_port_count(struct host_cmd_handler_args *args) { struct ec_response_charge_port_count *resp = args->response; @@ -1232,7 +1232,8 @@ DECLARE_HOST_COMMAND(EC_CMD_CHARGE_PORT_COUNT, hc_charge_port_count, EC_VER_MASK(0)); -static int hc_charge_port_override(struct host_cmd_handler_args *args) +static enum ec_status +hc_charge_port_override(struct host_cmd_handler_args *args) { const struct ec_params_charge_port_override *p = args->params; const int16_t override_port = p->override_port; @@ -1249,7 +1250,7 @@ DECLARE_HOST_COMMAND(EC_CMD_PD_CHARGE_PORT_OVERRIDE, EC_VER_MASK(0)); #if CONFIG_DEDICATED_CHARGE_PORT_COUNT > 0 -static int hc_override_dedicated_charger_limit( +static enum ec_status hc_override_dedicated_charger_limit( struct host_cmd_handler_args *args) { const struct ec_params_dedicated_charger_limit *p = args->params; @@ -1326,7 +1327,8 @@ static void charge_manager_external_power_limit_off(void) DECLARE_HOOK(HOOK_CHIPSET_SUSPEND, charge_manager_external_power_limit_off, HOOK_PRIO_DEFAULT); -static int hc_external_power_limit(struct host_cmd_handler_args *args) +static enum ec_status +hc_external_power_limit(struct host_cmd_handler_args *args) { const struct ec_params_external_power_limit_v1 *p = args->params; -- cgit v1.2.1