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: Subbaraman Narayanamurthy <subbaram@codeaurora.org>
This commit is contained in:
Subbaraman Narayanamurthy 2016-10-03 18:33:19 -07:00
parent 906f1b29ae
commit 110f63422b
2 changed files with 9 additions and 0 deletions

View file

@ -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;

View file

@ -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) {