From cc80d2bed27d5fee1cf046641c64b7dd2a12e00c Mon Sep 17 00:00:00 2001 From: Daisuke Nojiri Date: Fri, 26 Oct 2018 12:46:35 -0700 Subject: Battery: Force data update for EC_CMD_BATTERY_GET_STATIC Currently, EC_CMD_BATTERY_GET_STATIC reads static data which was updated previously. Since static data is updated only on special conditions, it causes the command to return stale data. This change makes the command force data update. Signed-off-by: Daisuke Nojiri BUG=b:117938291 BRANCH=none TEST=buildall Change-Id: I7acdfe5bac5ab87001ee57bd053c7cef411dfdd1 Reviewed-on: https://chromium-review.googlesource.com/1302834 Commit-Ready: Daisuke Nojiri Tested-by: Daisuke Nojiri Reviewed-by: Randall Spangler --- common/battery.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/common/battery.c b/common/battery.c index 9252fb9a94..21e6563b2b 100644 --- a/common/battery.c +++ b/common/battery.c @@ -445,6 +445,7 @@ DECLARE_HOST_COMMAND(EC_CMD_BATTERY_VENDOR_PARAM, #ifdef CONFIG_BATTERY_V2 #ifdef CONFIG_HOSTCMD_BATTERY_V2 +static void battery_update(enum battery_index i); static int host_command_battery_get_static(struct host_cmd_handler_args *args) { const struct ec_params_battery_static_info *p = args->params; @@ -452,7 +453,7 @@ static int host_command_battery_get_static(struct host_cmd_handler_args *args) if (p->index < 0 || p->index >= CONFIG_BATTERY_COUNT) return EC_RES_INVALID_PARAM; - + battery_update(p->index); args->response_size = sizeof(*r); memcpy(r, &battery_static[p->index], sizeof(*r)); -- cgit v1.2.1