summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenny Ho <hsiufangho@google.com>2023-06-21 15:26:55 +0800
committerJenny Ho <hsiufangho@google.com>2023-07-07 00:29:16 +0000
commit4807566a5dfe7d500db4eefa8d2ac1c2b898976b (patch)
tree8217bb666982ba0fd65da9d7abe6a828bb5bc009
parent467493ac0c0e09f4e22c94cdb559730f997e09f6 (diff)
downloadbms-4807566a5dfe7d500db4eefa8d2ac1c2b898976b.tar.gz
max1720x_battery: hold sleep for get property
Bug: 288031105 Change-Id: Ic1af1002a6622334c2db35b7cc05796c1cb61426 Signed-off-by: Jenny Ho <hsiufangho@google.com>
-rw-r--r--max1720x_battery.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/max1720x_battery.c b/max1720x_battery.c
index 629b742..12c3e63 100644
--- a/max1720x_battery.c
+++ b/max1720x_battery.c
@@ -265,6 +265,8 @@ struct max1720x_chip {
/* battery current criteria for report status charge */
u32 status_charge_threshold_ma;
+
+ struct wakeup_source *get_prop_ws;
};
#define MAX1720_EMPTY_VOLTAGE(profile, temp, cycle) \
@@ -2190,12 +2192,14 @@ static int max1720x_get_property(struct power_supply *psy,
u16 data = 0;
int idata;
+ __pm_stay_awake(chip->get_prop_ws);
mutex_lock(&chip->model_lock);
pm_runtime_get_sync(chip->dev);
if (!chip->init_complete || !chip->resume_complete) {
pm_runtime_put_sync(chip->dev);
mutex_unlock(&chip->model_lock);
+ __pm_relax(chip->get_prop_ws);
return -EAGAIN;
}
pm_runtime_put_sync(chip->dev);
@@ -2309,6 +2313,7 @@ static int max1720x_get_property(struct power_supply *psy,
chip->model_reload != MAX_M5_LOAD_MODEL_REQUEST) {
/* trigger reload model and clear of POR */
mutex_unlock(&chip->model_lock);
+ __pm_relax(chip->get_prop_ws);
max1720x_fg_irq_thread_fn(-1, chip);
return err;
}
@@ -2409,6 +2414,8 @@ static int max1720x_get_property(struct power_supply *psy,
pr_debug("error %d reading prop %d\n", err, psp);
mutex_unlock(&chip->model_lock);
+ __pm_relax(chip->get_prop_ws);
+
return err;
}
@@ -5737,6 +5744,10 @@ static void max1720x_init_work(struct work_struct *work)
ret = batt_ce_load_data(&chip->regmap_nvram, &chip->cap_estimate);
if (ret == 0)
batt_ce_dump_data(&chip->cap_estimate, chip->ce_log);
+
+ chip->get_prop_ws = wakeup_source_register(NULL, "GetProp");
+ if (!chip->get_prop_ws)
+ dev_info(chip->dev, "failed to register wakeup sources\n");
}
/* TODO: fix detection of 17301 for non samples looking at FW version too */
@@ -6150,6 +6161,8 @@ static int max1720x_remove(struct i2c_client *client)
if (chip->secondary)
i2c_unregister_device(chip->secondary);
+ wakeup_source_unregister(chip->get_prop_ws);
+
return 0;
}