From 54525158d2bf110391202190f62a61556bd6a0e5 Mon Sep 17 00:00:00 2001 From: "Dustin L. Howett" Date: Sat, 22 Jan 2022 18:38:56 -0600 Subject: [PATCH 1/2] Do not reset charge_max_level during CHG_LIMIT_GET_LIMIT Fixes #6. --- board/hx20/battery.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/board/hx20/battery.c b/board/hx20/battery.c index f7d43a94cf..a4d83fe39d 100644 --- a/board/hx20/battery.c +++ b/board/hx20/battery.c @@ -363,8 +363,9 @@ static enum ec_status cmd_charging_limit_control(struct host_cmd_handler_args *a charging_maximum_level = charging_maximum_level | CHG_LIMIT_OVERRIDE; if (p->modes & CHG_LIMIT_GET_LIMIT) { - system_get_bbram(SYSTEM_BBRAM_IDX_CHG_MAX, &charging_maximum_level); - r->max_percentage = charging_maximum_level; + uint8_t max = 0; + system_get_bbram(SYSTEM_BBRAM_IDX_CHG_MAX, &max); + r->max_percentage = max; args->response_size = sizeof(*r); } From fa84901d21a17e26270cd8d16e3c67d725c99665 Mon Sep 17 00:00:00 2001 From: "Dustin L. Howett" Date: Sun, 23 Jan 2022 13:59:43 -0600 Subject: [PATCH 2/2] In fact, don't use a temporary at all --- board/hx20/battery.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/board/hx20/battery.c b/board/hx20/battery.c index a4d83fe39d..6547a7b936 100644 --- a/board/hx20/battery.c +++ b/board/hx20/battery.c @@ -363,9 +363,7 @@ static enum ec_status cmd_charging_limit_control(struct host_cmd_handler_args *a charging_maximum_level = charging_maximum_level | CHG_LIMIT_OVERRIDE; if (p->modes & CHG_LIMIT_GET_LIMIT) { - uint8_t max = 0; - system_get_bbram(SYSTEM_BBRAM_IDX_CHG_MAX, &max); - r->max_percentage = max; + system_get_bbram(SYSTEM_BBRAM_IDX_CHG_MAX, &r->max_percentage); args->response_size = sizeof(*r); }