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

Commit 1a1255ec authored by David Keitel's avatar David Keitel
Browse files

power: qpnp-charger: don't allow ULPM usage when charging disabled



Some platforms do not have the battery interface
peripheral initialized. This may result in an
unauthorized access to a PMIC register with
offset 0 and cause the device to crash.

Fix this by not allowing the usage of ULPM for
boards that do not have the bat_if_base address
initialized or in which chip->charging_disabled is set.

Change-Id: I055451bfd1b2f7eb535e57e68a21d6ded41f0a55
Signed-off-by: default avatarDavid Keitel <dkeitel@codeaurora.org>
parent dc077d46
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -1181,6 +1181,9 @@ qpnp_chg_regulator_batfet_set(struct qpnp_chg_chip *chip, bool enable)
{
	int rc = 0;

	if (chip->charging_disabled || !chip->bat_if_base)
		return rc;

	if (chip->type == SMBB)
		rc = qpnp_chg_masked_write(chip,
			chip->bat_if_base + CHGR_BAT_IF_SPARE,
@@ -2465,6 +2468,9 @@ qpnp_chg_bat_if_batfet_reg_enabled(struct qpnp_chg_chip *chip)
	int rc = 0;
	u8 reg = 0;

	if (!chip->bat_if_base)
		return rc;

	if (chip->type == SMBB)
		rc = qpnp_chg_read(chip, &reg,
				chip->bat_if_base + CHGR_BAT_IF_SPARE, 1);