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

Commit 864934ff authored by Guru Das Srinagesh's avatar Guru Das Srinagesh
Browse files

power: battery: Don't allow USB ICL callback to set CP ILIM for WLS



Whenever a change in USB ICL leads to setting the CP ILIM, check whether
DC is present first; don't set the CP ILIM if it is.

Change-Id: I8d6ca6b62c4d0475e332d67696c6167452e72139
Signed-off-by: default avatarGuru Das Srinagesh <gurus@codeaurora.org>
parent 757c4610
Loading
Loading
Loading
Loading
+16 −3
Original line number Diff line number Diff line
@@ -1109,7 +1109,7 @@ static int usb_icl_vote_callback(struct votable *votable, void *data,
	int rc;
	struct pl_data *chip = data;
	union power_supply_propval pval = {0, };
	bool rerun_aicl = false;
	bool rerun_aicl = false, dc_present = false;

	if (!chip->main_psy)
		return 0;
@@ -1171,8 +1171,21 @@ static int usb_icl_vote_callback(struct votable *votable, void *data,

	/* Configure ILIM based on AICL result only if input mode is USBMID */
	if (cp_get_parallel_mode(chip, PARALLEL_INPUT_MODE)
					== POWER_SUPPLY_PL_USBMID_USBMID)
					== POWER_SUPPLY_PL_USBMID_USBMID) {
		if (chip->dc_psy) {
			rc = power_supply_get_property(chip->dc_psy,
					POWER_SUPPLY_PROP_PRESENT, &pval);
			if (rc < 0) {
				pr_err("Couldn't get DC PRESENT rc=%d\n", rc);
				return rc;
			}
			dc_present = pval.intval;
		}

		/* Don't configure ILIM if DC is present */
		if (!dc_present)
			cp_configure_ilim(chip, ICL_CHANGE_VOTER, icl_ua);
	}

	return 0;
}