max1720x_battery: prevent saving reset data into eeprom
We update eeprom cycle when read cycle register, but cycle register
reset to 0 when POR and we shouldn't update this data into eeprom.
However, there is a timing between read cycle register and check POR.
It is possible to read cycle earlier than detect POR and save 0 into
eeprom. Add check reset value and do not save into eeprom.
Bug: 213394909
Signed-off-by: Jenny Ho <[email protected]>
Change-Id: Idcd7cf4f4d83d73813524bb669db4d3992e2de8b
diff --git a/max1720x_battery.c b/max1720x_battery.c
index e1c498e..1601a6b 100644
--- a/max1720x_battery.c
+++ b/max1720x_battery.c
@@ -1430,7 +1430,7 @@
if (chip->gauge_type != MAX_M5_GAUGE_TYPE)
return eeprom_cycle;
- if (chip->por)
+ if (chip->por || reg_cycle == 0)
return eeprom_cycle;
/* save half value to record over 655 cycles case */