google_bms: revert using non-zero cc_max tier as last

Test: use fake_temp to switch temp tiers and ensure charging resumes
Bug: 367850696
Signed-off-by: Prasanna Prapancham <[email protected]>
(cherry picked from commit 0c5e550c3fb5d40598d54b44054b854031d20969)
(cherry picked from https://partner-android-review.googlesource.com/q/commit:fc8e030ab726daaf9dac6caf0408abcec911f8d0)
Merged-In: Iaa51de3c538d21d5eb1b7f5ae139ccc57e2871cb
Change-Id: Iaa51de3c538d21d5eb1b7f5ae139ccc57e2871cb
diff --git a/google_bms.c b/google_bms.c
index 16a5a9a..328ea64 100644
--- a/google_bms.c
+++ b/google_bms.c
@@ -747,16 +747,15 @@
 {
 	int cc_max;
 	int vbatt_idx = 0;
-	const int vbatt_last_idx = gbms_msc_get_last_voltage_idx(profile, temp_idx);
 
 	if (!profile)
 		return 0;
 
-	while (vbatt_idx < vbatt_last_idx &&
+	while (vbatt_idx < profile->volt_nb_limits - 1 &&
 	       vbatt > profile->volt_limits[vbatt_idx])
 		vbatt_idx++;
 
-	if (vbatt_idx != vbatt_last_idx) {
+	if (vbatt_idx != profile->volt_nb_limits - 1) {
 		const int vt = profile->volt_limits[vbatt_idx];
 		const int headr = profile->fv_uv_resolution * 3;
 
@@ -768,7 +767,7 @@
 		return vbatt_idx;
 
 	cc_max = GBMS_CCCM_LIMITS(profile, temp_idx, vbatt_idx);
-	while (vbatt_idx < vbatt_last_idx - 1 &&
+	while (vbatt_idx < profile->volt_nb_limits - 2 &&
 		cc_max == GBMS_CCCM_LIMITS(profile, temp_idx, vbatt_idx + 1))
 			vbatt_idx++;