Skip to contentSkip to conversation

charger-manager: Fix bug when check dropped voltage after fullbatt event

PATCH New [email protected] 1 participant 1 message Nov 22, 2012

lore
Share & tools
lore
#0 lore raw

PATCH 2/3 charger-manager: Fix bug when check dropped voltage after fullbatt event

From: Chanwoo Choi <[email protected]>

This patch check difference value between current voltage of battery and desc->fullbatt_uV whether positve or negative number. If difference value is negative number when current voltage of battery is larger than desc->fullbatt_uV, charger-manager return immediately because battery is fully charged.

---
 drivers/power/charger-manager.c |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)
drivers/power/charger-manager.c +6 -3
index ee039b9..17130c7 100644
@@ -468,7 +468,9 @@ static void fullbatt_vchk(struct work_struct *work)
 	struct charger_manager *cm = container_of(dwork,
 			struct charger_manager, fullbatt_vchk_work);
 	struct charger_desc *desc = cm->desc;
-	int batt_uV, err, diff;
+	int batt_uV;
+	int err;
+	int diff;
 
 	/* remove the appointment for fullbatt_vchk */
 	cm->fullbatt_vchk_jiffies_at = 0;
@@ -482,8 +484,9 @@ static void fullbatt_vchk(struct work_struct *work)
 		return;
 	}
 
-	diff = desc->fullbatt_uV;
-	diff -= batt_uV;
+	diff = desc->fullbatt_uV - batt_uV;
+	if (diff < 0)
+		return;
 
 	dev_info(cm->dev, "VBATT dropped %duV after full-batt.\n", diff);
 
Signature · 1 line
1.7.0.4