diff options
author | Jenny Ho <hsiufangho@google.com> | 2024-02-05 20:41:07 +0800 |
---|---|---|
committer | Jenny Ho <hsiufangho@google.com> | 2024-02-05 12:54:44 +0000 |
commit | 36c2a4d58e3e3ef1440dcc6512ae73b7b7d18559 (patch) | |
tree | 1fccc5a026276e0f2d16fc3ff77626e3a9720621 | |
parent | fb03bae03784f2b36738ce1dc81a257300f861a0 (diff) | |
download | bms-36c2a4d58e3e3ef1440dcc6512ae73b7b7d18559.tar.gz |
max1720x_battery: check gauge_type before accessing max_m5 functionsandroid-u-qpr3-beta-2_r0.7android-u-qpr3-beta-2_r0.6android-u-qpr3-beta-2_r0.5android-u-qpr3-beta-2_r0.4android-u-qpr3-beta-2_r0.3android-u-qpr3-beta-2_r0.2android-15-dp-2_r0.6android-15-dp-2_r0.5android-15-dp-2_r0.3android-15-dp-2_r0.2android-15-dp-2_r0.1
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.c | 3 |
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); |