From: Danke Xie Date: Tue, 16 Oct 2012 22:24:41 +0000 (-0700) Subject: power: android-battery: Allow changing current in charging state X-Git-Tag: firefly_0821_release~4090^2~648 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=552584f55d43677d46edaec00b2d1aad4337d657;p=firefly-linux-kernel-4.4.55.git 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 Signed-off-by: Todd Poynor --- diff --git a/drivers/power/android_battery.c b/drivers/power/android_battery.c index a5b5f65e019c..dbba090a51e1 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: