power: pm8921-charger: fix state of charge reporting

When the battery is missing the BMS is currently still used to
calculate the state of charge.

Fix this by reporting the voltage based state of charge when the
battery is missing.

Change-Id: I8eb265193b5bfb953add8731e9f47723cf301891
Signed-off-by: David Keitel <dkeitel@codeaurora.org>
diff --git a/drivers/power/pm8921-charger.c b/drivers/power/pm8921-charger.c
index 1454ca9..d24ce3f 100644
--- a/drivers/power/pm8921-charger.c
+++ b/drivers/power/pm8921-charger.c
@@ -1223,9 +1223,19 @@
 		    / (high_voltage - low_voltage);
 }
 
+static int get_prop_batt_present(struct pm8921_chg_chip *chip)
+{
+	return pm_chg_get_rt_status(chip, BATT_INSERTED_IRQ);
+}
+
 static int get_prop_batt_capacity(struct pm8921_chg_chip *chip)
 {
-	int percent_soc = pm8921_bms_get_percent_charge();
+	int percent_soc;
+
+	if (!get_prop_batt_present(chip))
+		percent_soc = voltage_based_capacity(chip);
+	else
+		percent_soc = pm8921_bms_get_percent_charge();
 
 	if (percent_soc == -ENXIO)
 		percent_soc = voltage_based_capacity(chip);
@@ -1278,11 +1288,6 @@
 	return POWER_SUPPLY_HEALTH_GOOD;
 }
 
-static int get_prop_batt_present(struct pm8921_chg_chip *chip)
-{
-	return pm_chg_get_rt_status(chip, BATT_INSERTED_IRQ);
-}
-
 static int get_prop_charge_type(struct pm8921_chg_chip *chip)
 {
 	int temp;