battery: Current rate must be positive.
ACPI disallows a negative current rate.
Use the absolute rate, and rely on the flags to indicate
charging or discharging.
TEST=zmake build nivviks
BRANCH=none
#include "console.h"
#include "hooks.h"
#include "host_command.h"
+#include "math_util.h"
#include "printf.h"
#include "util.h"
@@ -68,7 +69,11 @@ static void battery_update(enum battery_index i)
batt_str[EC_MEMMAP_TEXT_MAX - 1] = 0;
*memmap_volt = battery_dynamic[i].actual_voltage;
- *memmap_rate = battery_dynamic[i].actual_current;
+ /*
+ * Rate must be absolute, flags will indicate whether
+ * the battery is charging or discharging.
+ */
+ *memmap_rate = ABS(battery_dynamic[i].actual_current);
*memmap_cap = battery_dynamic[i].remaining_capacity;
*memmap_lfcc = battery_dynamic[i].full_capacity;
*memmap_flags = battery_dynamic[i].flags;
