Commit 909a78b320b31ca9709d7ea5f602ec1bd2015192
Committed by
Anton Vorontsov
1 parent
a7d9ace4eb
Exists in
master
and in
4 other branches
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>
Showing 1 changed file with 12 additions and 6 deletions Side-by-side Diff
drivers/power/bq20z75.c
... | ... | @@ -318,12 +318,15 @@ |
318 | 318 | { |
319 | 319 | #define BASE_UNIT_CONVERSION 1000 |
320 | 320 | #define BATTERY_MODE_CAP_MULT_WATT (10 * BASE_UNIT_CONVERSION) |
321 | -#define TIME_UNIT_CONVERSION 600 | |
322 | -#define TEMP_KELVIN_TO_CELCIUS 2731 | |
321 | +#define TIME_UNIT_CONVERSION 60 | |
322 | +#define TEMP_KELVIN_TO_CELSIUS 2731 | |
323 | 323 | switch (psp) { |
324 | 324 | case POWER_SUPPLY_PROP_ENERGY_NOW: |
325 | 325 | case POWER_SUPPLY_PROP_ENERGY_FULL: |
326 | 326 | case POWER_SUPPLY_PROP_ENERGY_FULL_DESIGN: |
327 | + /* bq20z75 provides energy in units of 10mWh. | |
328 | + * Convert to µWh | |
329 | + */ | |
327 | 330 | val->intval *= BATTERY_MODE_CAP_MULT_WATT; |
328 | 331 | break; |
329 | 332 | |
330 | 333 | |
... | ... | @@ -337,14 +340,17 @@ |
337 | 340 | break; |
338 | 341 | |
339 | 342 | case POWER_SUPPLY_PROP_TEMP: |
340 | - /* bq20z75 provides battery tempreture in 0.1°K | |
341 | - * so convert it to 0.1°C */ | |
342 | - val->intval -= TEMP_KELVIN_TO_CELCIUS; | |
343 | - val->intval *= 10; | |
343 | + /* bq20z75 provides battery temperature in 0.1K | |
344 | + * so convert it to 0.1°C | |
345 | + */ | |
346 | + val->intval -= TEMP_KELVIN_TO_CELSIUS; | |
344 | 347 | break; |
345 | 348 | |
346 | 349 | case POWER_SUPPLY_PROP_TIME_TO_EMPTY_AVG: |
347 | 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 | 354 | val->intval *= TIME_UNIT_CONVERSION; |
349 | 355 | break; |
350 | 356 |