From 40a1e7fa75b9fd51cf62ee8d725a5b35d846dbd5 Mon Sep 17 00:00:00 2001 From: Randall Spangler Date: Thu, 7 Nov 2013 14:36:02 -0800 Subject: 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 Reviewed-on: https://chromium-review.googlesource.com/176154 --- common/battery.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'common/battery.c') 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))) { -- cgit v1.2.1