aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/power
diff options
context:
space:
mode:
authorBenson Leung <bleung@chromium.org>2011-02-27 20:41:48 -0500
committerAnton Vorontsov <cbouatmailru@gmail.com>2011-03-16 09:41:06 -0400
commit909a78b320b31ca9709d7ea5f602ec1bd2015192 (patch)
treee9a834db60278573fd24eedafe53c476e8040815 /drivers/power
parenta7d9ace4eb3a6a3c3fcb12fb05510c1893808263 (diff)
bq20z75: Fix time and temp units
Corrected temperature and time to empty/full conversions. Temperature is in 0.1°C, time is in seconds. Corrected units in comment. "Convert to µWh." Signed-off-by: Benson Leung <bleung@chromium.org> Acked-by: Rhyland Klein <rklein@nvidia.com> Signed-off-by: Anton Vorontsov <cbouatmailru@gmail.com>
Diffstat (limited to 'drivers/power')
-rw-r--r--drivers/power/bq20z75.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/drivers/power/bq20z75.c b/drivers/power/bq20z75.c
index 5615c92bef66..506585e31a5b 100644
--- a/drivers/power/bq20z75.c
+++ b/drivers/power/bq20z75.c
@@ -318,12 +318,15 @@ static void bq20z75_unit_adjustment(struct i2c_client *client,
318{ 318{
319#define BASE_UNIT_CONVERSION 1000 319#define BASE_UNIT_CONVERSION 1000
320#define BATTERY_MODE_CAP_MULT_WATT (10 * BASE_UNIT_CONVERSION) 320#define BATTERY_MODE_CAP_MULT_WATT (10 * BASE_UNIT_CONVERSION)
321#define TIME_UNIT_CONVERSION 600 321#define TIME_UNIT_CONVERSION 60
322#define TEMP_KELVIN_TO_CELCIUS 2731 322#define TEMP_KELVIN_TO_CELSIUS 2731
323 switch (psp) { 323 switch (psp) {
324 case POWER_SUPPLY_PROP_ENERGY_NOW: 324 case POWER_SUPPLY_PROP_ENERGY_NOW:
325 case POWER_SUPPLY_PROP_ENERGY_FULL: 325 case POWER_SUPPLY_PROP_ENERGY_FULL:
326 case POWER_SUPPLY_PROP_ENERGY_FULL_DESIGN: 326 case POWER_SUPPLY_PROP_ENERGY_FULL_DESIGN:
327 /* bq20z75 provides energy in units of 10mWh.
328 * Convert to µWh
329 */
327 val->intval *= BATTERY_MODE_CAP_MULT_WATT; 330 val->intval *= BATTERY_MODE_CAP_MULT_WATT;
328 break; 331 break;
329 332
@@ -337,14 +340,17 @@ static void bq20z75_unit_adjustment(struct i2c_client *client,
337 break; 340 break;
338 341
339 case POWER_SUPPLY_PROP_TEMP: 342 case POWER_SUPPLY_PROP_TEMP:
340 /* bq20z75 provides battery tempreture in 0.1°K 343 /* bq20z75 provides battery temperature in 0.1K
341 * so convert it to 0.1°C */ 344 * so convert it to 0.1°C
342 val->intval -= TEMP_KELVIN_TO_CELCIUS; 345 */
343 val->intval *= 10; 346 val->intval -= TEMP_KELVIN_TO_CELSIUS;
344 break; 347 break;
345 348
346 case POWER_SUPPLY_PROP_TIME_TO_EMPTY_AVG: 349 case POWER_SUPPLY_PROP_TIME_TO_EMPTY_AVG:
347 case POWER_SUPPLY_PROP_TIME_TO_FULL_AVG: 350 case POWER_SUPPLY_PROP_TIME_TO_FULL_AVG:
351 /* bq20z75 provides time to empty and time to full in minutes.
352 * Convert to seconds
353 */
348 val->intval *= TIME_UNIT_CONVERSION; 354 val->intval *= TIME_UNIT_CONVERSION;
349 break; 355 break;
350 356