max1720x_battery: reset gauge when abnormal data is detected
1. Enhance gauge checking behavior when boot up
2. fix possible load model in wrong time
Bug: 188857623
Signed-off-by: Jenny Ho <[email protected]>
Change-Id: I398274557322e70969c6a8e4bde66e05bdcde7c4
diff --git a/max1720x_battery.c b/max1720x_battery.c
index 0884a87..52da9d8 100644
--- a/max1720x_battery.c
+++ b/max1720x_battery.c
@@ -2048,6 +2048,9 @@
pm_runtime_put_sync(chip->dev);
mutex_unlock(&chip->model_lock);
+ if (!chip->model_state_valid)
+ return -EAGAIN;
+
switch (psp) {
case GBMS_PROP_BATT_CE_CTRL:
@@ -3589,7 +3592,7 @@
if (chip->model_reload >= MAX_M5_LOAD_MODEL_REQUEST) {
const unsigned long delay = msecs_to_jiffies(60 * 1000);
- schedule_delayed_work(&chip->model_work, delay);
+ mod_delayed_work(system_wq, &chip->model_work, delay);
}
if (new_model) {