max1720x_battery: update cycle_count after model loading

the cycle count reset to 0 when fg reset, need to read back after fg
reset and model loading done

Bug: 312098789
Change-Id: I5ce133a8c8df1b340961090aa94e031de0e0f507
Signed-off-by: Jenny Ho <[email protected]>
(cherry picked from commit ccf717d6e84c62ecadca2f97b6c87a0f674a8dd4)
diff --git a/max1720x_battery.c b/max1720x_battery.c
index e39a766..8acbbf0 100644
--- a/max1720x_battery.c
+++ b/max1720x_battery.c
@@ -280,6 +280,7 @@
 static int max1720x_set_next_update(struct max1720x_chip *chip);
 static int max1720x_monitor_log_data(struct max1720x_chip *chip, bool force_log);
 static int max17201_init_rc_switch(struct max1720x_chip *chip);
+static int max1720x_update_cycle_count(struct max1720x_chip *chip);
 
 static bool max17x0x_reglog_init(struct max1720x_chip *chip)
 {
@@ -1533,6 +1534,8 @@
 		ret = REGMAP_WRITE_VERIFY(&chip->regmap, MAX1720X_CYCLES, eeprom_cycle);
 		if (ret < 0)
 			dev_warn(chip->dev, "fail to update cycles (%d)", ret);
+		else
+			max1720x_update_cycle_count(chip);
 	}
 }
 
@@ -5058,6 +5061,7 @@
 
 	/* max_m5 triggers loading of the model in the irq handler on POR */
 	if (!chip->por && chip->gauge_type == MAX_M5_GAUGE_TYPE) {
+		max1720x_update_cycle_count(chip);
 		ret = max1720x_init_max_m5(chip);
 		if (ret < 0)
 			return ret;
@@ -5781,8 +5785,6 @@
 	 */
 	max1720x_fg_irq_thread_fn(-1, chip);
 
-	max1720x_update_cycle_count(chip);
-
 	max1720x_update_timer_base(chip);
 
 	dev_info(chip->dev, "init_work done\n");