mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-24 21:54:34 -04:00
FG: RT9426A add safeguard for ocv_index
ocv_index is used for ocv_table parameter. In some case read a invalid ocv_indes(65535/-13),then driver read the wrong ocv parameter, that make checksum fail and exit the driver. the ocv_index only 0~4 is valid, if read a invalid ocv_index, using the default ocv_index to fix above issue. Change-Id: I633aaa7f9abc4a98abb72cbec45025c8c52d5662 Signed-off-by: liuyc20 <liuyc20@lenovo.com> Reviewed-on: https://gerrit.mot.com/2151514 SME-Granted: SME Approvals Granted SLTApproved: Slta Waiver Tested-by: Jira Key Reviewed-by: Huosheng Liao <liaohs@motorola.com> Submit-Approved: Jira Key
This commit is contained in:
parent
2d3b0cbc54
commit
881e346bc6
1 changed files with 7 additions and 1 deletions
|
|
@ -2285,11 +2285,17 @@ static int rt9426a_apply_pdata(struct rt9426a_chip *chip)
|
|||
u8 page_idx=0,extend_reg_cmd_addr=0, array_idx=0;
|
||||
int volt_now = 0, fd_vth_now = 0, fd_threshold = 0;
|
||||
int wt_ocv_result = RT9426A_WRITE_OCV_FAIL;
|
||||
int ocv_index = 0;
|
||||
|
||||
dev_info(chip->dev, "%s\n", __func__);
|
||||
|
||||
/* read ocv_index before using it */
|
||||
chip->ocv_index = rt9426a_reg_read_word(chip->i2c, RT9426A_REG_RSVD2);
|
||||
ocv_index = rt9426a_reg_read_word(chip->i2c, RT9426A_REG_RSVD2);
|
||||
/* ocv_index only 0~4 is valid, if read a invalid ocv_index, using the default ocv_index */
|
||||
if (ocv_index < 0 || ocv_index > 4)
|
||||
chip->ocv_index = 0;
|
||||
else
|
||||
chip->ocv_index = ocv_index;
|
||||
dev_info(chip->dev, "%s: ocv_index = %d\n",
|
||||
__func__, chip->ocv_index);
|
||||
/* update ocv_checksum_dtsi after ocv_index updated */
|
||||
|
|
|
|||
Loading…
Reference in a new issue