From: Todd Poynor Date: Thu, 4 Oct 2012 23:11:53 +0000 (-0700) Subject: power: android-battery: leave full/not-charging status when charger re-sensed X-Git-Tag: firefly_0821_release~4090^2~659 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=8873f5de286b40ccf6ead25bfcebe21e82a907ae;p=firefly-linux-kernel-4.4.55.git power: android-battery: leave full/not-charging status when charger re-sensed If charger was connected and a charge source change event occurs such that the charger is still connected (or a different charge source connected), do not overwrite an existing state such as full or not-charging. Only switch from discharging to charging on a charge source change event. Change-Id: I1b841c8f3a92bf15074999e18b17d1d19ce028d7 Signed-off-by: Todd Poynor --- diff --git a/drivers/power/android_battery.c b/drivers/power/android_battery.c index d6ff01adcd08..d7682d69e3ab 100644 --- a/drivers/power/android_battery.c +++ b/drivers/power/android_battery.c @@ -399,8 +399,18 @@ static void android_bat_charger_work(struct work_struct *work) break; case CHARGE_SOURCE_USB: case CHARGE_SOURCE_AC: - battery->charging_status = POWER_SUPPLY_STATUS_CHARGING; - android_bat_enable_charging(battery, true); + /* + * If charging status indicates a charger was already + * connected prior to this and a non-charging status is + * set, 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_CHARGING; + android_bat_enable_charging(battery, true); + } + break; default: pr_err("%s: Invalid charger type\n", __func__);