aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDanke Xie <d.xie@sta.samsung.com>2012-10-16 15:24:41 -0700
committerJohn Stultz <john.stultz@linaro.org>2012-12-04 20:10:01 -0500
commitff704cafc26b0c8d0c3b7231e54d6e0a48881f79 (patch)
tree56364989ff0e8adc0360aa1a72ce92bb11c551ac
parente91b6837c57d0c4dd83fe2fbeb753f60322a9d3b (diff)
power: android-battery: Allow changing current in charging state
When a new charge source is set, enable charging and set the charging current, unless we've paused charging due to battery full or battery health problems. Change-Id: I129e621c455a941e264dc431b4eb9db6a17c9f7b Signed-off-by: Danke Xie <d.xie@sta.samsung.com> Signed-off-by: Todd Poynor <toddpoynor@google.com>
-rw-r--r--drivers/power/android_battery.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/drivers/power/android_battery.c b/drivers/power/android_battery.c
index 94a2ccfa28cb..e0cefafbfb96 100644
--- a/drivers/power/android_battery.c
+++ b/drivers/power/android_battery.c
@@ -412,15 +412,24 @@ static void android_bat_charger_work(struct work_struct *work)
case CHARGE_SOURCE_AC:
/*
* If charging status indicates a charger was already
- * connected prior to this and a non-charging status is
- * set, leave the status alone.
+ * connected prior to this and the status is something
+ * other than charging ("full" or "not-charging"), leave
+ * the status alone.
*/
if (battery->charging_status ==
POWER_SUPPLY_STATUS_DISCHARGING ||
- battery->charging_status == POWER_SUPPLY_STATUS_UNKNOWN) {
+ battery->charging_status == POWER_SUPPLY_STATUS_UNKNOWN)
battery->charging_status = POWER_SUPPLY_STATUS_CHARGING;
+
+ /*
+ * Don't re-enable charging if the battery is full and we
+ * are not actively re-charging it, or if "not-charging"
+ * status is set.
+ */
+ if (!((battery->charging_status == POWER_SUPPLY_STATUS_FULL
+ && !battery->recharging) || battery->charging_status ==
+ POWER_SUPPLY_STATUS_NOT_CHARGING))
android_bat_enable_charging(battery, true);
- }
break;
default: