summaryrefslogtreecommitdiffstats
path: root/drivers/power
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/power')
-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/**