From ffbc67dcac2d03bc5967627ebd9dba37e7013e5a Mon Sep 17 00:00:00 2001 From: Ikjoon Jang Date: Thu, 11 Mar 2021 14:46:51 +0800 Subject: virtual_battery: bug fix in reading SB_AVERAGE_CURRENT Fix a bug from CL:2747559, virtual battery returns an error for SB_AVERAGE_CURRENT. virtual battery handler should call battery_get_avg_current(), not battery_get_avg_voltage(). BRANCH=none BUG=b:170921599 TEST=read current_avg knob in kukui Signed-off-by: Ikjoon Jang Change-Id: I90c26a8e1d4fa6faccc0166b9f7b63fca9baef51 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2751320 Reviewed-by: Ting Shen --- driver/battery/smart.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'driver/battery/smart.c') diff --git a/driver/battery/smart.c b/driver/battery/smart.c index b0ccec8de9..1c2dcaf4c9 100644 --- a/driver/battery/smart.c +++ b/driver/battery/smart.c @@ -318,7 +318,6 @@ test_mockable int battery_device_chemistry(char *dest, int size) return sb_read_string(SB_DEVICE_CHEMISTRY, dest, size); } -#ifdef CONFIG_CMD_PWR_AVG int battery_get_avg_current(void) { int current; @@ -328,6 +327,7 @@ int battery_get_avg_current(void) return (int16_t)current; } +#ifdef CONFIG_CMD_PWR_AVG /* * Technically returns only the instantaneous reading, but tests showed that * for the majority of charge states above 3% this varies by less than 40mV @@ -386,6 +386,8 @@ void battery_get_params(struct batt_params *batt) else batt_new.current = (int16_t)v; + if (sb_read(SB_AVERAGE_CURRENT, &v)) + batt_new.flags |= BATT_FLAG_BAD_AVERAGE_CURRENT; if (sb_read(SB_CHARGING_VOLTAGE, &batt_new.desired_voltage)) batt_new.flags |= BATT_FLAG_BAD_DESIRED_VOLTAGE; -- cgit v1.2.1