aboutsummaryrefslogtreecommitdiff
path: root/drivers/power
diff options
context:
space:
mode:
authorJohan Palsson <johan.palsson@stericsson.com>2011-01-28 08:17:23 +0100
committerJonas ABERG <jonas.aberg@stericsson.com>2011-02-01 11:31:20 +0100
commitb6eb776fd1a46abf32881ba6242d89885ea71c65 (patch)
tree9ce380d64a8fff362e6fc1226fd73ed11d3a25a2 /drivers/power
parent5208b3a98412314b0615dc2bc340b434fd23f901 (diff)
power: ab8500_bm: Only report 0% capacity if LOW_BAT IRQ generated
We will not report 0% capacity unless we've got the LOW_BAT IRQ, no matter what the FG algorithm says. ST-Ericsson ID: ER321470 ST-Ericsson FOSS-OUT ID: Trivial Change-Id: I9cb85dfbb2f71d70b2f1596f4ed6ab17a991a7c0 Signed-off-by: Johan Palsson <johan.palsson@stericsson.com> Reviewed-on: http://gerrit.lud.stericsson.com/gerrit/13741 Reviewed-by: QATOOLS Reviewed-by: Johan GARDSMARK <johan.gardsmark@stericsson.com> Reviewed-by: Jonas ABERG <jonas.aberg@stericsson.com>
Diffstat (limited to 'drivers/power')
-rw-r--r--drivers/power/ab8500_fg.c23
1 files changed, 18 insertions, 5 deletions
diff --git a/drivers/power/ab8500_fg.c b/drivers/power/ab8500_fg.c
index e3788345579..2e3b8f3bb30 100644
--- a/drivers/power/ab8500_fg.c
+++ b/drivers/power/ab8500_fg.c
@@ -865,12 +865,25 @@ static void ab8500_fg_check_capacity_limits(struct ab8500_fg *di, bool init)
di->bat_cap.mah = 0;
changed = true;
} else if (di->bat_cap.prev_percent != di->bat_cap.permille / 10) {
- /*
- * We do not allow reported capacity to go up
- * unless we're charging or if we're in init
- */
- if (!(!di->flags.charging && (di->bat_cap.permille / 10) >
+ if (di->bat_cap.permille / 10 == 0) {
+ /*
+ * We will not report 0% unless we've got
+ * the LOW_BAT IRQ, no matter what the FG
+ * algorithm says.
+ */
+ di->bat_cap.prev_percent = 1;
+ di->bat_cap.permille = 1;
+ di->bat_cap.prev_mah = 1;
+ di->bat_cap.mah = 1;
+
+ changed = true;
+ } else if (!(!di->flags.charging &&
+ (di->bat_cap.permille / 10) >
di->bat_cap.prev_percent) || init) {
+ /*
+ * We do not allow reported capacity to go up
+ * unless we're charging or if we're in init
+ */
dev_dbg(di->dev,
"capacity changed from %d to %d (%d)\n",
di->bat_cap.prev_percent,