summaryrefslogtreecommitdiff
path: root/drivers/power
diff options
context:
space:
mode:
authorDaniel Mack <daniel@caiaq.de>2009-07-15 20:20:41 +0400
committerAnton Vorontsov <cbouatmailru@gmail.com>2009-07-30 17:37:06 +0400
commit25f2bfa62ae77820a8185734c4a2ab7f3971a2fc (patch)
tree2809f7c45ed0e379cf11d3c2a6aa98d5d7996156 /drivers/power
parentc1e72193ea3fa02e96bf3aa66006e18d107d0266 (diff)
downloadlinux-25f2bfa62ae77820a8185734c4a2ab7f3971a2fc.tar.xz
ds2760_battery: handle full_active_uAh == 0 case correctly
In systems where the battery monitor is not part of the battery pack and is hence not bootstrapped with sane values, the full_active_uAh is likely to be zero. Handle that case by defaulting to the rated_capacity information which can be passed to the driver using the new module parameter. Signed-off-by: Daniel Mack <daniel@caiaq.de> Cc: Szabolcs Gyurko <szabolcs.gyurko@tlt.hu> Acked-by: Matt Reimer <mreimer@vpop.net> Signed-off-by: Anton Vorontsov <cbouatmailru@gmail.com>
Diffstat (limited to 'drivers/power')
-rw-r--r--drivers/power/ds2760_battery.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/drivers/power/ds2760_battery.c b/drivers/power/ds2760_battery.c
index ed0ea5e275c5..2d0e5edb4742 100644
--- a/drivers/power/ds2760_battery.c
+++ b/drivers/power/ds2760_battery.c
@@ -172,8 +172,13 @@ static int ds2760_battery_read_status(struct ds2760_device_info *di)
di->full_active_uAh = di->raw[DS2760_ACTIVE_FULL] << 8 |
di->raw[DS2760_ACTIVE_FULL + 1];
- scale[0] = di->raw[DS2760_ACTIVE_FULL] << 8 |
- di->raw[DS2760_ACTIVE_FULL + 1];
+ /* If the full_active_uAh value is not given, fall back to the rated
+ * capacity. This is likely to happen when chips are not part of the
+ * battery pack and is therefore not bootstrapped. */
+ if (di->full_active_uAh == 0)
+ di->full_active_uAh = di->rated_capacity / 1000L;
+
+ scale[0] = di->full_active_uAh;
for (i = 1; i < 5; i++)
scale[i] = scale[i - 1] + di->raw[DS2760_ACTIVE_FULL + 2 + i];