Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 557d7b68 authored by Fenglin Wu's avatar Fenglin Wu
Browse files

power: smb5-lib: Load HW JEITA config in general psy events



Currently, JEITA configuration is updated with a BMS event. There
is a chance that BMS is not updating with a long time and that would
cause the JEITA configuration is not loaded and JEITA is mis-triggered,
so update the JEITA configuration in general power supply events and
defer the updating if BMS power supply is not ready.

Change-Id: Ib3b792ea8fc64083ea14b7ea5a00565815a0cec6
Signed-off-by: default avatarFenglin Wu <fenglinw@codeaurora.org>
parent 20768179
Loading
Loading
Loading
Loading
+11 −2
Original line number Diff line number Diff line
@@ -731,9 +731,10 @@ static int smblib_notifier_call(struct notifier_block *nb,
			chg->bms_psy = psy;
		if (ev == PSY_EVENT_PROP_CHANGED)
			schedule_work(&chg->bms_update_work);
	}

	if (!chg->jeita_configured)
		schedule_work(&chg->jeita_update_work);
	}

	if (chg->sec_pl_present && !chg->pl.psy
		&& !strcmp(psy->desc->name, "parallel")) {
@@ -4086,6 +4087,10 @@ static void jeita_update_work(struct work_struct *work)
		goto out;
	}

	/* if BMS is not ready, defer the work */
	if (!chg->bms_psy)
		return;

	rc = power_supply_get_property(chg->bms_psy,
			POWER_SUPPLY_PROP_RESISTANCE_ID, &val);
	if (rc < 0) {
@@ -4093,6 +4098,10 @@ static void jeita_update_work(struct work_struct *work)
		goto out;
	}

	/* if BMS hasn't read out the batt_id yet, defer the work */
	if (val.intval <= 0)
		return;

	pnode = of_batterydata_get_best_profile(batt_node,
					val.intval / 1000, NULL);
	if (IS_ERR(pnode)) {