power: supply: qti_battery_charger: Handle state only if driver is initialized

There is a chance that battery_chg_state_cb() can get invoked before the
battery charger driver finishes initialization. Handle it.

Change-Id: If959b00d3055e0194184b5c3992b0c0906d29213
Signed-off-by: Subbaraman Narayanamurthy <quic_subbaram@quicinc.com>
This commit is contained in:
Subbaraman Narayanamurthy 2022-08-03 17:37:51 -07:00
parent b57cad08fb
commit 8e42f9587d

View File

@ -494,6 +494,11 @@ static void battery_chg_state_cb(void *priv, enum pmic_glink_state state)
pr_debug("state: %d\n", state);
if (!bcdev->initialized) {
pr_warn("Driver not initialized, pmic_glink state %d\n", state);
return;
}
atomic_set(&bcdev->state, state);
if (state == PMIC_GLINK_STATE_UP)
schedule_work(&bcdev->subsys_up_work);