summaryrefslogtreecommitdiff
path: root/common/charge_manager.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/charge_manager.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/charge_manager.c')
-rw-r--r--common/charge_manager.c12
1 files changed, 7 insertions, 5 deletions
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;