From: xuwei9 Date: Wed, 24 Apr 2019 06:02:57 +0000 (+0800) Subject: kernel:tro(CR) battery profile update X-Git-Tag: MMI-RSBS31.Q1-48-36-26~178 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=9b41a510c497c05592d39f7b84f81623145b8907;p=GitHub%2FMotorolaMobilityLLC%2Fkernel-slsi.git kernel:tro(CR) battery profile update tro(CR) battery profile update for local buy battery Change-Id: I13ad4fe4471814c79645eeeb6d3842814d2b3ea6 Signed-off-by: xuwei9 Reviewed-on: https://gerrit.mot.com/1341251 SLTApproved: Slta Waiver SME-Granted: SME Approvals Granted Tested-by: Jira Key Reviewed-by: Xiangpo Zhao Submit-Approved: Jira Key --- diff --git a/drivers/power/supply/s2mu106_fuelgauge.c b/drivers/power/supply/s2mu106_fuelgauge.c index 4aba762dec8e..3846f5603727 100755 --- a/drivers/power/supply/s2mu106_fuelgauge.c +++ b/drivers/power/supply/s2mu106_fuelgauge.c @@ -1507,16 +1507,18 @@ static const char *fg_get_mmi_battid(void) static int fg_get_serialnumber(struct s2mu106_fuelgauge_data *chip, struct device_node *np) { - const char *sn_buf, *df_sn, *dev_sn; + const char *sn_buf, *df_sn, *dev_sn,*sn_buf_local_buy; int rc; int battery_cell1 = 0; int battery_cell2 = 1; int battery_index = 0; + int battery_default_index = 0; bool battery_matched = false; dev_sn = NULL; df_sn = NULL; sn_buf = NULL; + sn_buf_local_buy = NULL; chip->battery_profile_index = 0; dev_sn = fg_get_mmi_battid(); @@ -1536,30 +1538,70 @@ static int fg_get_serialnumber(struct s2mu106_fuelgauge_data *chip, if (rc) pr_info("%s, No cell1 Serial Number defined", __func__); else { - if ((dev_sn && strnstr(dev_sn, sn_buf, 32)) || (df_sn && strnstr(df_sn, sn_buf, 32))) { + if (dev_sn && strnstr(dev_sn, sn_buf, 32) ) { battery_matched = true; battery_index = battery_cell1; } + + if (df_sn && strnstr(df_sn, sn_buf, 32)) { + battery_default_index = battery_cell1; + } } + rc = of_property_read_string(np, "serialnum_cell1_local_buy", + &sn_buf_local_buy); + if (rc) + pr_info("%s, No cell1 Serial local buy Number defined", __func__); + else { + if ((dev_sn && strnstr(dev_sn, sn_buf_local_buy, 32)) ) { + battery_matched = true; + battery_index = battery_cell1; + } + + if ((df_sn && strnstr(df_sn, sn_buf_local_buy, 32))) { + battery_default_index = battery_cell1; + } + } + rc = of_property_read_string(np, "serialnum_cell2", &sn_buf); if (rc) pr_info("%s,No cell2 Serial Number defined", __func__); else { - if ((dev_sn && strnstr(dev_sn, sn_buf, 32)) || (df_sn && strnstr(df_sn, sn_buf, 32))) { + if ((dev_sn && strnstr(dev_sn, sn_buf, 32)) ) { battery_matched = true; battery_index = battery_cell2; } + + if ((df_sn && strnstr(df_sn, sn_buf, 32))) { + battery_default_index = battery_cell2; + } } - if (battery_matched) - pr_info("%s, battery matched index:%d", __func__, battery_index); - else - pr_info("%s, battery did not matched , use default index:%d", __func__, battery_index); - chip->battery_profile_index = battery_index; + rc = of_property_read_string(np, "serialnum_cell2_local_buy", + &sn_buf_local_buy); + if (rc) + pr_info("%s,No cell2 local buy Serial Number defined", __func__); + else { + if ((dev_sn && strnstr(dev_sn, sn_buf_local_buy, 32)) ) { + battery_matched = true; + battery_index = battery_cell2; + } + + if ((df_sn && strnstr(df_sn, sn_buf_local_buy, 32))) { + battery_default_index = battery_cell2; + } + } + + if (battery_matched){ + pr_info("%s, battery matched index:%d", __func__, battery_index); + chip->battery_profile_index = battery_index; + } else { + pr_info("%s, battery did not matched , use default index:%d", __func__, battery_default_index); + chip->battery_profile_index = battery_default_index; + } - return battery_index; + return chip->battery_profile_index; } static void s2mu106_fuelgauge_select_table(struct s2mu106_fuelgauge_data *fuelgauge)