diff options
author | HongMin Son <hongmin.son@samsung.com> | 2012-10-11 19:42:54 +0900 |
---|---|---|
committer | John Stultz <john.stultz@linaro.org> | 2012-12-04 20:09:59 -0500 |
commit | e91b6837c57d0c4dd83fe2fbeb753f60322a9d3b (patch) | |
tree | 0d7235f8119e53da2e75c6b56bd5c9c9755a791d | |
parent | a521324a7fd287107b8128dc1a36d71a63e7bf1b (diff) |
power: android-battery: Battery health check only when connected to charger
Only check battery health when connected to a charger.
Change-Id: I43e3f73ac1e5862f8e6dbaa19daa6d322f3bba20
Signed-off-by: HongMin Son <hongmin.son@samsung.com>
-rw-r--r-- | drivers/power/android_battery.c | 47 |
1 files changed, 29 insertions, 18 deletions
diff --git a/drivers/power/android_battery.c b/drivers/power/android_battery.c index e6c4b4cd3e86..94a2ccfa28cb 100644 --- a/drivers/power/android_battery.c +++ b/drivers/power/android_battery.c @@ -201,28 +201,39 @@ static void android_bat_get_temp(struct android_bat_data *battery) if (battery->pdata->get_temperature) battery->pdata->get_temperature(&batt_temp); - if (batt_temp >= battery->pdata->temp_high_threshold) { - if (health != POWER_SUPPLY_HEALTH_OVERHEAT && + if (battery->charge_source != CHARGE_SOURCE_NONE) { + if (batt_temp >= battery->pdata->temp_high_threshold) { + if (health != POWER_SUPPLY_HEALTH_OVERHEAT && health != POWER_SUPPLY_HEALTH_UNSPEC_FAILURE) { - pr_info("battery overheat (%d>=%d), charging unavailable\n", - batt_temp, battery->pdata->temp_high_threshold); - battery->batt_health = POWER_SUPPLY_HEALTH_OVERHEAT; - } - } else if (batt_temp <= battery->pdata->temp_high_recovery && + pr_info("battery overheat (%d>=%d), " \ + "charging unavailable\n", + batt_temp, + battery->pdata->temp_high_threshold); + battery->batt_health = + POWER_SUPPLY_HEALTH_OVERHEAT; + } + } else if (batt_temp <= battery->pdata->temp_high_recovery && batt_temp >= battery->pdata->temp_low_recovery) { - if (health == POWER_SUPPLY_HEALTH_OVERHEAT || + if (health == POWER_SUPPLY_HEALTH_OVERHEAT || health == POWER_SUPPLY_HEALTH_COLD) { - pr_info("battery recovery (%d,%d~%d), charging available\n", - batt_temp, battery->pdata->temp_low_recovery, - battery->pdata->temp_high_recovery); - battery->batt_health = POWER_SUPPLY_HEALTH_GOOD; - } - } else if (batt_temp <= battery->pdata->temp_low_threshold) { - if (health != POWER_SUPPLY_HEALTH_COLD && + pr_info("battery recovery (%d,%d~%d)," \ + "charging available\n", + batt_temp, + battery->pdata->temp_low_recovery, + battery->pdata->temp_high_recovery); + battery->batt_health = + POWER_SUPPLY_HEALTH_GOOD; + } + } else if (batt_temp <= battery->pdata->temp_low_threshold) { + if (health != POWER_SUPPLY_HEALTH_COLD && health != POWER_SUPPLY_HEALTH_UNSPEC_FAILURE) { - pr_info("battery cold (%d <= %d), charging unavailable\n", - batt_temp, battery->pdata->temp_low_threshold); - battery->batt_health = POWER_SUPPLY_HEALTH_COLD; + pr_info("battery cold (%d <= %d)," \ + "charging unavailable\n", + batt_temp, + battery->pdata->temp_low_threshold); + battery->batt_health = + POWER_SUPPLY_HEALTH_COLD; + } } } |