Fix a bug that battery info is not updated when AC not connected

When AC power is not connected, EC doesn't update battery information in
mapped memory. This makes battery information unavailable is AC is not
present when EC boots.

BUG=chrome-os-partner:12858
TEST=Unplug AC and reset EC. Run ectool and check we can see battery
info.
BRANCH=link

Change-Id: I23339962a6aa1bbbf6806c1184b96e949466208f
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/30820
Reviewed-by: Rong Chang <rongchang@chromium.org>
This commit is contained in:
Vic Yang
2012-08-18 18:36:20 +08:00
committed by Gerrit
parent 1f091487b2
commit 088a248c79

View File

@@ -289,6 +289,9 @@ static enum power_state state_init(struct power_state_context *ctx)
charger_set_current(0);
charger_set_voltage(0);
/* Update static battery info */
update_battery_info();
/* If AC is not present, switch to discharging state */
if (!ctx->curr.ac)
return PWR_STATE_DISCHARGE;
@@ -297,9 +300,6 @@ static enum power_state state_init(struct power_state_context *ctx)
if (ctx->curr.error)
return PWR_STATE_ERROR;
/* Update static battery info */
update_battery_info();
/* Send battery event to host */
host_set_single_event(EC_HOST_EVENT_BATTERY);