mmi_parallel_charger: optimize temp zone structure

-1, set temp_c as signed constant
-2, add conditional judgment to prevent invalid temp zone

Change-Id: I7ed0fe09034c5669f1538954ebf871e1ed7cf0e7
Signed-off-by: xuwt2 <xuwt2@lenovo.com>
Reviewed-on: https://gerrit.mot.com/1408609
SME-Granted: SME Approvals Granted
SLTApproved: Slta Waiver
Tested-by: Jira Key
Reviewed-by: Jianqi Yang <yangj@motorola.com>
Submit-Approved: Jira Key
Reviewed-on: https://gerrit.mot.com/1893549
Reviewed-by: Xiangpo Zhao <zhaoxp3@motorola.com>
Reviewed-by: Wei Xu <xuwei9@lenovo.com>
This commit is contained in:
xuwt2 2019-08-23 14:23:59 +08:00 • committed by Wei Xu
commit 616e6682fb
2 changed files with 4 additions and 3 deletions

View file

@ -113,7 +113,7 @@ bool mmi_find_temp_zone(struct mmi_charger_manager *chip, int temp_c)
colder_t = zones[prev_zone - 1].temp_c;
}
if (temp_c < MIN_TEMP_C)
if (temp_c <= MIN_TEMP_C)
chip->pres_temp_zone = ZONE_COLD;
else if (temp_c >= max_temp)
chip->pres_temp_zone = ZONE_HOT;
@ -151,7 +151,8 @@ bool mmi_find_chrg_step(struct mmi_charger_manager *chip, int temp_zone, int vba
}
if (chip->pres_temp_zone == ZONE_HOT ||
chip->pres_temp_zone == ZONE_COLD) {
chip->pres_temp_zone == ZONE_COLD ||
chip->pres_temp_zone < ZONE_FIRST) {
mmi_chrg_err(chip, "pres temp zone is HOT or COLD, "
"can't find chrg step\n");
return false;

View file

@ -101,7 +101,7 @@ struct mmi_chrg_step_power {
};
struct mmi_chrg_temp_zone {
u32 temp_c; /*temperature*/
int temp_c; /*temperature*/
struct mmi_chrg_step_power *chrg_step_power;
};