power: ds2781: Fix for ACR 100% reset
authorGreg Meiste <w30289@motorola.com>
Wed, 3 Nov 2010 14:19:56 +0000 (09:19 -0500)
committerDima Zavin <dima@android.com>
Wed, 3 Nov 2010 18:58:18 +0000 (11:58 -0700)
Only do the reset if the percentage is valid.  This fixes the scenario
where the reset is incorrectly attempted on power up.

Change-Id: If62de88bf10f363389127328d0f5448821e7beea
Signed-off-by: Greg Meiste <w30289@motorola.com>
Signed-off-by: Dima Zavin <dima@android.com>
drivers/power/ds2781_battery.c

index 519c6aa3ee2d6c0bf78bf54f69d2b0d377ed0edd..533c0c8a6f31d21805b73a782c0c968f2c7e4c12 100644 (file)
@@ -385,7 +385,9 @@ static void ds2781_battery_alarm(struct alarm *alarm)
 
 static void ds2781_reset_if_necessary(struct ds2781_device_info *di)
 {
-       if (di->status.percentage < 100) {
+       /* If we have read from the DS2781 and the percentage is not 100%,
+        * the ACR should be reset. */
+       if (di->raw[DS2781_REG_RSNSP] && (di->status.percentage < 100)) {
                dev_err(di->dev, "Charge complete before 100 percent.\n");
                dev_err(di->dev, "Resetting ACR registers to Full 40 value.\n");