summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenny Ho <hsiufangho@google.com>2024-02-05 20:41:07 +0800
committerJenny Ho <hsiufangho@google.com>2024-02-05 12:54:44 +0000
commit36c2a4d58e3e3ef1440dcc6512ae73b7b7d18559 (patch)
tree1fccc5a026276e0f2d16fc3ff77626e3a9720621
parentfb03bae03784f2b36738ce1dc81a257300f861a0 (diff)
downloadbms-36c2a4d58e3e3ef1440dcc6512ae73b7b7d18559.tar.gz
This file handles both max77759 and max17201 FG, only max77759 FG allows accesses to max_m5 related functions, adds gauge type checking to prevent kernel panic Bug: 318106590 Change-Id: Ia5d5301cb2db4304ace2d3acc2d5d3b2c6c39c25 Signed-off-by: Jenny Ho <hsiufangho@google.com>
-rw-r--r--max1720x_battery.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/max1720x_battery.c b/max1720x_battery.c
index 63349e1..d27896e 100644
--- a/max1720x_battery.c
+++ b/max1720x_battery.c
@@ -1658,7 +1658,8 @@ static int max1720x_update_cycle_count(struct max1720x_chip *chip)
return -ECANCELED;
/* if cycle reg hasn't been restored from storage, restore it before update cycle count */
- if (!chip->cycle_reg_ok && max_m5_recal_state(chip->model_data) == RE_CAL_STATE_IDLE) {
+ if (!chip->cycle_reg_ok && chip->gauge_type == MAX_M5_GAUGE_TYPE &&
+ max_m5_recal_state(chip->model_data) == RE_CAL_STATE_IDLE) {
err = max1720x_restore_battery_cycle(chip);
if (err < 0)
dev_err(chip->dev, "%s cannot restore cycle count (%d)\n", __func__, err);