From 318557af840588d1c0e95b505f828abbf39363e4 Mon Sep 17 00:00:00 2001 From: Ting Shen Date: Mon, 2 Dec 2019 15:27:57 +0800 Subject: kodama: overwrite bad battery params to known good value Kodama's bitbang driver fails randomly, and there's no way to notify kernel side that bitbang read failed (batt->flags does not propagate into kernel). Thus, if any value in batt_params is bad, replace it with a cached good value, to make sure we never send random numbers to kernel side. BUG=b:144195782 TEST=Modify smart battery driver to make sb_read has 50% fail rate, and monitor /sys/class/power_supply/sbs*/*, make sure the bad values does not observable in kernel. BRANCH=kukui Change-Id: Idf4691eb743f1ef785593b308b8f07a34e5ea642 Signed-off-by: Ting Shen Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1943637 Reviewed-by: Eric Yilun Lin Reviewed-by: Daisuke Nojiri Commit-Queue: Ting Shen Tested-by: Ting Shen Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3872709 Tested-by: Daisuke Nojiri Auto-Submit: Daisuke Nojiri Reviewed-by: Ting Shen Commit-Queue: Daisuke Nojiri --- driver/battery/smart.c | 1 + 1 file changed, 1 insertion(+) (limited to 'driver/battery/smart.c') diff --git a/driver/battery/smart.c b/driver/battery/smart.c index cc3ef73c29..51a04d3b6b 100644 --- a/driver/battery/smart.c +++ b/driver/battery/smart.c @@ -398,6 +398,7 @@ void battery_get_params(struct batt_params *batt) #ifdef HAS_TASK_HOSTCMD /* if there is no host, we don't care about compensation */ battery_compensate_params(&batt_new); + board_battery_compensate_params(&batt_new); #endif /* Update visible battery parameters */ -- cgit v1.2.1