diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2012-12-19 11:14:08 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-12-19 11:14:08 -0500 |
commit | 5031a2a7c12b837a0913c4139ebeb6bbff5e1aa5 (patch) | |
tree | 17d870e89554f0e7ad66029c41f3477ebc371eff /drivers | |
parent | 7a684c452e2589f3ddd7e2d466b4f747d3715ad9 (diff) | |
parent | f36b9ddbab408f5f5ed9105d857189b84337af48 (diff) |
Merge tag 'for-v3.8-part2' of git://git.infradead.org/battery-2.6
Pull battery update, part 2, from Anton Vorontsov:
"These are left overs that I didn't have time to review/apply before
the merge window opened. I didn't want to "spoil" the first pull
request with these late patches, so they were not included:
- A small patch for the RX51 OMAP board (Nokia N900 phone), the patch
creates a battery monitor device instance, so that it can be
probed. It was acked by the OMAP maintainer;
- A couple of late bug fixes for the charger-manager: corrects corner
cases for the battery full handling."
* tag 'for-v3.8-part2' of git://git.infradead.org/battery-2.6:
charger-manager: Fix bug when check dropped voltage after fullbatt event
charger-manager: Fix bug related to checking fully charged state of battery
ARM: OMAP: rx51: Register platform device for rx51_battery
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/power/charger-manager.c | 38 |
1 files changed, 16 insertions, 22 deletions
diff --git a/drivers/power/charger-manager.c b/drivers/power/charger-manager.c index adb3a4b59cb3..6ba047f5ac2c 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 | |||
278 | out: | ||
279 | return val.intval ? true : false; | ||
280 | } | 273 | } |
281 | 274 | ||
282 | /** | 275 | /** |
@@ -489,8 +482,9 @@ static void fullbatt_vchk(struct work_struct *work) | |||
489 | return; | 482 | return; |
490 | } | 483 | } |
491 | 484 | ||
492 | diff = desc->fullbatt_uV; | 485 | diff = desc->fullbatt_uV - batt_uV; |
493 | diff -= batt_uV; | 486 | if (diff < 0) |
487 | return; | ||
494 | 488 | ||
495 | dev_info(cm->dev, "VBATT dropped %duV after full-batt.\n", diff); | 489 | dev_info(cm->dev, "VBATT dropped %duV after full-batt.\n", diff); |
496 | 490 | ||