power: pm8921-bms: calculate real_fcc

real_fcc is the remaining capacity in the battery when the charger
driver indicates that the battery is fully charged. This value needs
to be calculated when charging ends with a fully charged battery.

The userspace can read this value via module parameter and preserve it
between restarts.

The real reason for calculating this is to indicate how much the battery
capacity has dropped w.r.t  the profiled battery data use this deviation
in calculations.

Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
diff --git a/drivers/power/pm8921-charger.c b/drivers/power/pm8921-charger.c
index fba714e..257ad35 100644
--- a/drivers/power/pm8921-charger.c
+++ b/drivers/power/pm8921-charger.c
@@ -150,6 +150,7 @@
 };
 
 struct bms_notify {
+	int			is_battery_full;
 	int			is_charging;
 	struct	work_struct	work;
 };
@@ -755,10 +756,12 @@
 {
 	struct bms_notify *n = container_of(work, struct bms_notify, work);
 
-	if (n->is_charging)
+	if (n->is_charging) {
 		pm8921_bms_charging_began();
-	else
-		pm8921_bms_charging_end();
+	} else {
+		pm8921_bms_charging_end(n->is_battery_full);
+		n->is_battery_full = 0;
+	}
 }
 
 static void bms_notify_check(struct pm8921_chg_chip *chip)
@@ -1340,6 +1343,9 @@
 	power_supply_changed(&chip->usb_psy);
 	power_supply_changed(&chip->dc_psy);
 
+	chip->bms_notify.is_battery_full = 1;
+	bms_notify_check(chip);
+
 	/*
 	 * since charging is now done, start monitoring for
 	 * battery voltage below resume voltage