OSDN Git Service

Merge "power: qpnp-fg-gen3: add support for skew in capacity learning algorithm"
[sagit-ice-cold/kernel_xiaomi_msm8998.git] / drivers / power / supply / qcom / qpnp-fg-gen3.c
index df20a14..2d407a9 100644 (file)
@@ -1658,7 +1658,7 @@ static int fg_set_recharge_voltage(struct fg_chip *chip, int voltage_mv)
 static int fg_charge_full_update(struct fg_chip *chip)
 {
        union power_supply_propval prop = {0, };
-       int rc, msoc, bsoc, recharge_soc;
+       int rc, msoc, bsoc, recharge_soc, msoc_raw;
        u8 full_soc[2] = {0xFF, 0xFF};
 
        if (!chip->dt.hold_soc_while_full)
@@ -1694,6 +1694,7 @@ static int fg_charge_full_update(struct fg_chip *chip)
                pr_err("Error in getting msoc, rc=%d\n", rc);
                goto out;
        }
+       msoc_raw = DIV_ROUND_CLOSEST(msoc * FULL_SOC_RAW, FULL_CAPACITY);
 
        fg_dbg(chip, FG_STATUS, "msoc: %d bsoc: %x health: %d status: %d full: %d\n",
                msoc, bsoc, chip->health, chip->charge_status,
@@ -1717,7 +1718,7 @@ static int fg_charge_full_update(struct fg_chip *chip)
                        fg_dbg(chip, FG_STATUS, "Terminated charging @ SOC%d\n",
                                msoc);
                }
-       } else if ((bsoc >> 8) <= recharge_soc && chip->charge_full) {
+       } else if (msoc_raw < recharge_soc && chip->charge_full) {
                chip->delta_soc = FULL_CAPACITY - msoc;
 
                /*
@@ -1747,8 +1748,8 @@ static int fg_charge_full_update(struct fg_chip *chip)
                                rc);
                        goto out;
                }
-               fg_dbg(chip, FG_STATUS, "bsoc: %d recharge_soc: %d delta_soc: %d\n",
-                       bsoc >> 8, recharge_soc, chip->delta_soc);
+               fg_dbg(chip, FG_STATUS, "msoc_raw = %d bsoc: %d recharge_soc: %d delta_soc: %d\n",
+                       msoc_raw, bsoc >> 8, recharge_soc, chip->delta_soc);
        } else {
                goto out;
        }