aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChanwoo Choi <cw00.choi@samsung.com>2012-11-22 02:53:46 -0500
committerAnton Vorontsov <anton.vorontsov@linaro.org>2012-12-17 01:43:23 -0500
commit0fa11dbc234268c4160b81f67220308dea3c156a (patch)
treef4a5b8b87de1c9a2797f262faa056d4a96df2a37
parent7605c0b0d384ec98f80abc6ac2148a6cd993026c (diff)
charger-manager: Fix bug related to checking fully charged state of battery
This patch fix bug related to checking fully charged state of battery when charger-manager call is_full_charged() function. After reading property of charger/fuel-gauge through power_supply API, val.intval is more than 1. So, is_full_charged() function always return true. If true, battery means fully charged state. Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com> Signed-off-by: Myungjoo Ham <myungjoo.ham@samsung.com> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com> Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>
-rw-r--r--drivers/power/charger-manager.c33
1 files changed, 13 insertions, 20 deletions
diff --git a/drivers/power/charger-manager.c b/drivers/power/charger-manager.c
index adb3a4b59cb3..633e41ca49ac 100644
--- a/drivers/power/charger-manager.c
+++ b/drivers/power/charger-manager.c
@@ -239,44 +239,37 @@ static bool is_full_charged(struct charger_manager *cm)
239 int uV; 239 int uV;
240 240
241 /* If there is no battery, it cannot be charged */ 241 /* If there is no battery, it cannot be charged */
242 if (!is_batt_present(cm)) { 242 if (!is_batt_present(cm))
243 val.intval = 0; 243 return false;
244 goto out;
245 }
246 244
247 if (cm->fuel_gauge && desc->fullbatt_full_capacity > 0) { 245 if (cm->fuel_gauge && desc->fullbatt_full_capacity > 0) {
246 val.intval = 0;
247
248 /* Not full if capacity of fuel gauge isn't full */ 248 /* Not full if capacity of fuel gauge isn't full */
249 ret = cm->fuel_gauge->get_property(cm->fuel_gauge, 249 ret = cm->fuel_gauge->get_property(cm->fuel_gauge,
250 POWER_SUPPLY_PROP_CHARGE_FULL, &val); 250 POWER_SUPPLY_PROP_CHARGE_FULL, &val);
251 if (!ret && val.intval > desc->fullbatt_full_capacity) { 251 if (!ret && val.intval > desc->fullbatt_full_capacity)
252 val.intval = 1; 252 return true;
253 goto out;
254 }
255 } 253 }
256 254
257 /* Full, if it's over the fullbatt voltage */ 255 /* Full, if it's over the fullbatt voltage */
258 if (desc->fullbatt_uV > 0) { 256 if (desc->fullbatt_uV > 0) {
259 ret = get_batt_uV(cm, &uV); 257 ret = get_batt_uV(cm, &uV);
260 if (!ret && uV >= desc->fullbatt_uV) { 258 if (!ret && uV >= desc->fullbatt_uV)
261 val.intval = 1; 259 return true;
262 goto out;
263 }
264 } 260 }
265 261
266 /* Full, if the capacity is more than fullbatt_soc */ 262 /* Full, if the capacity is more than fullbatt_soc */
267 if (cm->fuel_gauge && desc->fullbatt_soc > 0) { 263 if (cm->fuel_gauge && desc->fullbatt_soc > 0) {
264 val.intval = 0;
265
268 ret = cm->fuel_gauge->get_property(cm->fuel_gauge, 266 ret = cm->fuel_gauge->get_property(cm->fuel_gauge,
269 POWER_SUPPLY_PROP_CAPACITY, &val); 267 POWER_SUPPLY_PROP_CAPACITY, &val);
270 if (!ret && val.intval >= desc->fullbatt_soc) { 268 if (!ret && val.intval >= desc->fullbatt_soc)
271 val.intval = 1; 269 return true;
272 goto out;
273 }
274 } 270 }
275 271
276 val.intval = 0; 272 return false;
277
278out:
279 return val.intval ? true : false;
280} 273}
281 274
282/** 275/**