summaryrefslogtreecommitdiff
path: root/common/battery.c
diff options
context:
space:
mode:
authorRandall Spangler <rspangler@chromium.org>2013-11-07 14:36:02 -0800
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2013-12-02 22:03:54 +0000
commit40a1e7fa75b9fd51cf62ee8d725a5b35d846dbd5 (patch)
tree0d403622ef503e01417e050ca6457ebf65e44643 /common/battery.c
parentc0ec787ba10dd3ef5fc089cf1449468ec45ff668 (diff)
downloadchrome-ec-40a1e7fa75b9fd51cf62ee8d725a5b35d846dbd5.tar.gz
Cleanly force battery to mAh mode when reading capacity
Smart batteries can report capacity in mAh or 10mW units. We forced the units to mAh in charge_state.c's main loop, but that doesn't guarantee that they're actually set before the capacity is read. It's cleaner to check the capacity reporting mode when actually reading the capacity. BUG=chrome-os-partner:20881 BRANCH=none TEST=battery command reports the same capacity data before/after change (on rambi, design=2940 mAh) Change-Id: I4a4c80eaade72bb09627d5d65693c097e264a992 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/176154
Diffstat (limited to 'common/battery.c')
-rw-r--r--common/battery.c10
1 files changed, 3 insertions, 7 deletions
diff --git a/common/battery.c b/common/battery.c
index 140b7d22c7..a8ece1d796 100644
--- a/common/battery.c
+++ b/common/battery.c
@@ -120,7 +120,6 @@ static void print_battery_info(void)
{
int value;
int hour, minute;
- const char *unit;
print_item_name("Serial:");
if (check_print_error(battery_serial_number(&value)))
@@ -134,24 +133,21 @@ static void print_battery_info(void)
if (check_print_error(battery_get_mode(&value)))
ccprintf("0x%04x\n", value);
- battery_is_in_10mw_mode(&value);
- unit = value ? "0 mW" : " mAh";
-
print_item_name("Abs charge:");
if (check_print_error(battery_state_of_charge_abs(&value)))
ccprintf("%d %%\n", value);
print_item_name("Remaining:");
if (check_print_error(battery_remaining_capacity(&value)))
- ccprintf("%d%s\n", value, unit);
+ ccprintf("%d mAh\n", value);
print_item_name("Cap-full:");
if (check_print_error(battery_full_charge_capacity(&value)))
- ccprintf("%d%s\n", value, unit);
+ ccprintf("%d mAh\n", value);
print_item_name(" Design:");
if (check_print_error(battery_design_capacity(&value)))
- ccprintf("%d%s\n", value, unit);
+ ccprintf("%d mAh\n", value);
print_item_name("Time-full:");
if (check_print_error(battery_time_to_full(&value))) {