Skip to content

Commit

Permalink
power: qpnp-fg: qpnp-qg: fg-alg: Improve code readability of TTF algo…
Browse files Browse the repository at this point in the history
…rithm

For voltage based step charging, used in TTF algorithm, improve the code
readability by changing ttf_mode from TTF_MODE_V_STEP_CHG to
TTF_MODE_VBAT_STEP_CHG.

Change-Id: Ia3b7dd0f2fc1b354c5afaa745c1117719fb9df66
Signed-off-by: Sahil Chandna <chandna@codeaurora.org>
  • Loading branch information
Sahil Chandna authored and Gerrit - the friendly Code Review server committed Jul 8, 2019
1 parent c458a23 commit 86cee62
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions drivers/power/supply/qcom/fg-alg.c
Original file line number Diff line number Diff line change
Expand Up @@ -898,7 +898,7 @@ static int get_step_chg_current_window(struct ttf *ttf)
struct range_data *step_chg_cfg = ttf->step_chg_cfg;
int i, rc, curr_window, vbatt;

if (ttf->mode == TTF_MODE_V_STEP_CHG) {
if (ttf->mode == TTF_MODE_VBAT_STEP_CHG) {
rc = ttf->get_ttf_param(ttf->data, TTF_VBAT, &vbatt);
if (rc < 0) {
pr_err("failed to get battery voltage, rc=%d\n", rc);
Expand Down Expand Up @@ -1024,7 +1024,7 @@ static int get_time_to_full_locked(struct ttf *ttf, int *val)
/* estimated battery current at the CC to CV transition */
switch (ttf->mode) {
case TTF_MODE_NORMAL:
case TTF_MODE_V_STEP_CHG:
case TTF_MODE_VBAT_STEP_CHG:
case TTF_MODE_OCV_STEP_CHG:
i_cc2cv = ibatt_avg * vbatt_avg /
max(MILLI_UNIT, float_volt_uv / MILLI_UNIT);
Expand Down Expand Up @@ -1082,7 +1082,7 @@ static int get_time_to_full_locked(struct ttf *ttf, int *val)
ibatt_this_step, t_predicted_this_step);
}
break;
case TTF_MODE_V_STEP_CHG:
case TTF_MODE_VBAT_STEP_CHG:
case TTF_MODE_OCV_STEP_CHG:
if (!step_chg_data || !step_chg_cfg)
break;
Expand Down Expand Up @@ -1123,7 +1123,7 @@ static int get_time_to_full_locked(struct ttf *ttf, int *val)
MILLI_UNIT);
}

if (ttf->mode == TTF_MODE_V_STEP_CHG)
if (ttf->mode == TTF_MODE_VBAT_STEP_CHG)
step_chg_data[i].ocv =
step_chg_cfg[i].high_threshold -
(rbatt * i_step);
Expand Down
2 changes: 1 addition & 1 deletion drivers/power/supply/qcom/fg-alg.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ struct cap_learning {
enum ttf_mode {
TTF_MODE_NORMAL = 0,
TTF_MODE_QNOVO,
TTF_MODE_V_STEP_CHG,
TTF_MODE_VBAT_STEP_CHG,
TTF_MODE_OCV_STEP_CHG,
};

Expand Down
2 changes: 1 addition & 1 deletion drivers/power/supply/qcom/qpnp-fg-gen4.c
Original file line number Diff line number Diff line change
Expand Up @@ -951,7 +951,7 @@ static int fg_gen4_get_ttf_param(void *data, enum ttf_param param, int *val)
if (is_qnovo_en(fg))
*val = TTF_MODE_QNOVO;
else if (chip->ttf->step_chg_cfg_valid)
*val = TTF_MODE_V_STEP_CHG;
*val = TTF_MODE_VBAT_STEP_CHG;
else if (chip->ttf->ocv_step_chg_cfg_valid)
*val = TTF_MODE_OCV_STEP_CHG;
else
Expand Down
2 changes: 1 addition & 1 deletion drivers/power/supply/qcom/qpnp-qg.c
Original file line number Diff line number Diff line change
Expand Up @@ -1615,7 +1615,7 @@ static int qg_get_ttf_param(void *data, enum ttf_param param, int *val)
break;
case TTF_MODE:
if (chip->ttf->step_chg_cfg_valid)
*val = TTF_MODE_V_STEP_CHG;
*val = TTF_MODE_VBAT_STEP_CHG;
else
*val = TTF_MODE_NORMAL;
break;
Expand Down

2 comments on commit 86cee62

@kholk
Copy link
Contributor

@kholk kholk commented on 86cee62 Jul 29, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit may break Sony extensions for Seine and/or for Tama/Kumano, please build check!

@stefanhh0
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The commit has been cherry-picked earlier, see: 7dff1e2

Please sign in to comment.