google_battery: adjust FAN_LEVEL update flow
- calculate fan level after update cc_max to get meaningful data
- update power_supply_changed when connected
Bug: 237802224
Signed-off-by: Jenny Ho <[email protected]>
Change-Id: I2e05538f1116d36ddda3a9beba913b2f183134a0
diff --git a/google_battery.c b/google_battery.c
index d21155e..c27efd3 100644
--- a/google_battery.c
+++ b/google_battery.c
@@ -1097,15 +1097,19 @@
pr_debug("FAN_LEVEL %d->%d reason=%s\n",
batt_drv->fan_last_level, lvl, reason ? reason : "<>");
- if (!chg_state_is_disconnected(&batt_drv->chg_state))
+ if (!chg_state_is_disconnected(&batt_drv->chg_state)) {
logbuffer_log(batt_drv->ttf_stats.ttf_log,
"FAN_LEVEL %d->%d reason=%s",
batt_drv->fan_last_level, lvl,
reason ? reason : "<>");
- batt_drv->fan_last_level = lvl;
- if (batt_drv->psy)
- power_supply_changed(batt_drv->psy);
+ batt_drv->fan_last_level = lvl;
+ if (batt_drv->psy)
+ power_supply_changed(batt_drv->psy);
+ } else {
+ /* Disconnected */
+ batt_drv->fan_last_level = lvl;
+ }
}
return 0;
@@ -4419,15 +4423,6 @@
batt_drv->cc_max = 0;
}
- /* Fan level can be updated only during power transfer */
- if (batt_drv->fan_level_votable) {
- int level = fan_calculate_level(batt_drv);
-
- gvotable_cast_int_vote(batt_drv->fan_level_votable,
- "MSC_BATT", level, true);
- pr_debug("MSC_FAN_LVL: level=%d\n", level);
- }
-
if (changed)
log_vote_level = BATT_PRLOG_ALWAYS;
batt_prlog(log_vote_level,
@@ -4509,6 +4504,15 @@
}
}
+ /* Fan level can be updated only during power transfer */
+ if (batt_drv->fan_level_votable) {
+ int level = fan_calculate_level(batt_drv);
+
+ gvotable_cast_int_vote(batt_drv->fan_level_votable,
+ "MSC_BATT", level, true);
+ pr_debug("MSC_FAN_LVL: level=%d\n", level);
+ }
+
if (!batt_drv->msc_interval_votable)
batt_drv->msc_interval_votable =
gvotable_election_get_handle(VOTABLE_MSC_INTERVAL);