power: pm8921-bms: fix soc reporting 0

When charging starts from very low voltages start_percent will be
calculated as zero. Zero value for start_percent is also used as
a flag to indicate the device did not start charging.
This further causes soc reporting zero value all the time.

Fix this by setting the start_percent and end_percent to -EINVAL when
charging has not started.

Change-Id: I88f8861828b5d8929a5eda04ac9726404a1559c2
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
diff --git a/drivers/power/pm8921-bms.c b/drivers/power/pm8921-bms.c
index c671465..0af181b 100644
--- a/drivers/power/pm8921-bms.c
+++ b/drivers/power/pm8921-bms.c
@@ -1087,7 +1087,7 @@
 	 * the device must be charging for reporting a higher soc, if not ignore
 	 * this soc and continue reporting the last_soc
 	 */
-	if (the_chip->start_percent != 0) {
+	if (the_chip->start_percent != -EINVAL) {
 		last_soc = soc;
 	} else {
 		pr_debug("soc = %d reporting last_soc = %d\n", soc, last_soc);
@@ -1340,8 +1340,8 @@
 			the_chip->end_percent,
 			last_charge_increase,
 			last_chargecycles);
-	the_chip->start_percent = 0;
-	the_chip->end_percent = 0;
+	the_chip->start_percent = -EINVAL;
+	the_chip->end_percent = -EINVAL;
 }
 EXPORT_SYMBOL_GPL(pm8921_bms_charging_end);
 
@@ -1825,6 +1825,8 @@
 	chip->v_failure = pdata->v_failure;
 	chip->calib_delay_ms = pdata->calib_delay_ms;
 	chip->max_voltage_uv = pdata->max_voltage_uv;
+	chip->start_percent = -EINVAL;
+	chip->end_percent = -EINVAL;
 	rc = set_battery_data(chip);
 	if (rc) {
 		pr_err("%s bad battery data %d\n", __func__, rc);