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

Commit 110f6342 authored by Subbaraman Narayanamurthy's avatar Subbaraman Narayanamurthy
Browse files

qpnp-fg-gen3: fg-util: Do not allow SRAM access when battery is missing



When the battery is removed and a strong charger is plugged in,
device will be kept powered. However, because of missing battery
SRAM access over IMA can fail leading to errors. Eventually, the
errors will go away when the battery is inserted again. However,
if the user tries to access SRAM registers or bms power supply
properties, it can cause further errors flooding logs. Handle
this gracefully by returning an error upon battery missing is
detected.

CRs-Fixed: 1072401
Change-Id: I764442548cb076dad89856d75394ef9cf355f83a
Signed-off-by: default avatarSubbaraman Narayanamurthy <subbaram@codeaurora.org>
parent 906f1b29
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -83,6 +83,9 @@ int fg_sram_write(struct fg_chip *chip, u16 address, u8 offset,
	if (!chip)
		return -ENXIO;

	if (chip->battery_missing)
		return -ENODATA;

	if (!fg_sram_address_valid(address, len))
		return -EFAULT;

@@ -147,6 +150,9 @@ int fg_sram_read(struct fg_chip *chip, u16 address, u8 offset,
	if (!chip)
		return -ENXIO;

	if (chip->battery_missing)
		return -ENODATA;

	if (!fg_sram_address_valid(address, len))
		return -EFAULT;

+3 −0
Original line number Diff line number Diff line
@@ -438,6 +438,9 @@ static int fg_get_sram_prop(struct fg_chip *chip, enum fg_sram_param_id id,
	if (id < 0 || id > FG_SRAM_MAX || chip->sp[id].len > sizeof(buf))
		return -EINVAL;

	if (chip->battery_missing)
		return -ENODATA;

	rc = fg_sram_read(chip, chip->sp[id].addr_word, chip->sp[id].addr_byte,
		buf, chip->sp[id].len, FG_IMA_DEFAULT);
	if (rc < 0) {