diff options
author | Alec Berg <alecaberg@chromium.org> | 2015-09-28 08:07:43 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2015-10-06 22:57:08 -0700 |
commit | 9669eeede24a9bae19cc000213265632a63e5d80 (patch) | |
tree | 08ad4e0e85fe1a0b2ebc1b9bb55f18e515376e2f /common | |
parent | f7022544bffac0964300405eb878b114d14128ae (diff) | |
download | chrome-ec-9669eeede24a9bae19cc000213265632a63e5d80.tar.gz |
charge_state_v2: fix battfake command race condition
This moves battfake console command to the battery driver.
This fixes a race condition with using the 'battfake' command
where charge_state_v2 could return the real battery percentage
even when a faked percentage is specified, if a higher priority
task uses the battery state of charge in between when the
battery is read, and when the fake state of charge overwrites
the battery parameter.
BUG=chrome-os-partner:45878
BRANCH=none
TEST=use tap for battery with a faked state of charge. the tap
for battery queries the battery percentage a lot, so without
this CL, the tap sequence often temporarily jumps to different
percentages and colors. with this CL, the tap sequence works
great.
Change-Id: I3ae0866d1ff7bb8d0c51355cd6b958310766f19e
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/302711
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Diffstat (limited to 'common')
-rw-r--r-- | common/charge_state_v2.c | 31 |
1 files changed, 0 insertions, 31 deletions
diff --git a/common/charge_state_v2.c b/common/charge_state_v2.c index 630ee06d74..0d89d470ce 100644 --- a/common/charge_state_v2.c +++ b/common/charge_state_v2.c @@ -62,7 +62,6 @@ static int battery_was_removed; static int problems_exist; static int debugging; -static int fake_state_of_charge = -1; /* Track problems in communicating with the battery or charger */ @@ -618,12 +617,6 @@ void charger_task(void) curr.chg.flags |= CHG_FLAG_INITIALIZED; - /* Fake state of charge if necessary */ - if (fake_state_of_charge >= 0) { - curr.batt.state_of_charge = fake_state_of_charge; - curr.batt.flags &= ~BATT_FLAG_BAD_STATE_OF_CHARGE; - } - /* * TODO(crosbug.com/p/27527). Sometimes the battery thinks its * temperature is 6280C, which seems a bit high. Let's ignore @@ -1167,30 +1160,6 @@ DECLARE_HOST_COMMAND(EC_CMD_CHARGE_STATE, charge_command_charge_state, /*****************************************************************************/ /* Console commands */ -static int command_battfake(int argc, char **argv) -{ - char *e; - int v; - - if (argc == 2) { - v = strtoi(argv[1], &e, 0); - if (*e || v < -1 || v > 100) - return EC_ERROR_PARAM1; - - fake_state_of_charge = v; - } - - if (fake_state_of_charge >= 0) - ccprintf("Fake batt %d%%\n", - fake_state_of_charge); - - return EC_SUCCESS; -} -DECLARE_CONSOLE_COMMAND(battfake, command_battfake, - "percent (-1 = use real level)", - "Set fake battery level", - NULL); - static int command_chgstate(int argc, char **argv) { int rv; |