[prev in list] [next in list] [prev in thread] [next in thread] 

List:       git-commits-head
Subject:    olpc_battery: Ensure that the TRICKLE bit is checked
From:       Linux Kernel Mailing List <linux-kernel () vger ! kernel ! org>
Date:       2009-07-30 23:59:43
Message-ID: 200907302359.n6UNxhGn024061 () hera ! kernel ! org
[Download RAW message or body]

Gitweb:     http://git.kernel.org/linus/8f7e57985fa794ab6afdcd3642581d9e1fe6de31
Commit:     8f7e57985fa794ab6afdcd3642581d9e1fe6de31
Parent:     04a820ead0838c76e9c1242feb5e71048bf3e9dc
Author:     Andres Salomon <dilinger@collabora.co.uk>
AuthorDate: Tue Jun 30 02:16:17 2009 -0400
Committer:  Anton Vorontsov <cbouatmailru@gmail.com>
CommitDate: Wed Jul 1 02:36:58 2009 +0400

    olpc_battery: Ensure that the TRICKLE bit is checked
    
    There are times when the battery is present but trickle charging,
    and the EC sets only the TRICKLE bit. So we must check for the bit
    when we're checking the charging/present status.
    
    Signed-off-by: Andres Salomon <dilinger@collabora.co.uk>
    Signed-off-by: Anton Vorontsov <cbouatmailru@gmail.com>
---
 drivers/power/olpc_battery.c |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/power/olpc_battery.c b/drivers/power/olpc_battery.c
index 9c216dd..58e4192 100644
--- a/drivers/power/olpc_battery.c
+++ b/drivers/power/olpc_battery.c
@@ -36,6 +36,7 @@
 #define BAT_STAT_AC		0x10
 #define BAT_STAT_CHARGING	0x20
 #define BAT_STAT_DISCHARGING	0x40
+#define BAT_STAT_TRICKLE	0x80
 
 #define BAT_ERR_INFOFAIL	0x02
 #define BAT_ERR_OVERVOLTAGE	0x04
@@ -90,7 +91,7 @@ static char bat_serial[17]; /* Ick */
 static int olpc_bat_get_status(union power_supply_propval *val, uint8_t ec_byte)
 {
 	if (olpc_platform_info.ecver > 0x44) {
-		if (ec_byte & BAT_STAT_CHARGING)
+		if (ec_byte & (BAT_STAT_CHARGING | BAT_STAT_TRICKLE))
 			val->intval = POWER_SUPPLY_STATUS_CHARGING;
 		else if (ec_byte & BAT_STAT_DISCHARGING)
 			val->intval = POWER_SUPPLY_STATUS_DISCHARGING;
@@ -220,7 +221,8 @@ static int olpc_bat_get_property(struct power_supply *psy,
 	   It doesn't matter though -- the EC will return the last-known
 	   information, and it's as if we just ran that _little_ bit faster
 	   and managed to read it out before the battery went away. */
-	if (!(ec_byte & BAT_STAT_PRESENT) && psp != POWER_SUPPLY_PROP_PRESENT)
+	if (!(ec_byte & (BAT_STAT_PRESENT | BAT_STAT_TRICKLE)) &&
+			psp != POWER_SUPPLY_PROP_PRESENT)
 		return -ENODEV;
 
 	switch (psp) {
@@ -230,7 +232,8 @@ static int olpc_bat_get_property(struct power_supply *psy,
 			return ret;
 		break;
 	case POWER_SUPPLY_PROP_PRESENT:
-		val->intval = !!(ec_byte & BAT_STAT_PRESENT);
+		val->intval = !!(ec_byte & (BAT_STAT_PRESENT |
+					    BAT_STAT_TRICKLE));
 		break;
 
 	case POWER_SUPPLY_PROP_HEALTH:
--
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic