diff options
author | Ikjoon Jang <ikjn@chromium.org> | 2021-03-11 14:46:51 +0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-03-15 11:09:37 +0000 |
commit | ffbc67dcac2d03bc5967627ebd9dba37e7013e5a (patch) | |
tree | 730b4ba290df687a74842d20565e9193f8b0064b /driver/battery/smart.c | |
parent | fd9ea2bfe6a9b0dbf40ad3aa36409063db15ce06 (diff) | |
download | chrome-ec-ffbc67dcac2d03bc5967627ebd9dba37e7013e5a.tar.gz |
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 <ikjn@chromium.org>
Change-Id: I90c26a8e1d4fa6faccc0166b9f7b63fca9baef51
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2751320
Reviewed-by: Ting Shen <phoenixshen@chromium.org>
Diffstat (limited to 'driver/battery/smart.c')
-rw-r--r-- | driver/battery/smart.c | 4 |
1 files changed, 3 insertions, 1 deletions
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; |