diff options
author | Pali Rohár <pali.rohar@gmail.com> | 2013-02-02 05:06:09 -0500 |
---|---|---|
committer | Anton Vorontsov <anton@enomsg.org> | 2013-02-02 22:44:08 -0500 |
commit | 5dc3443eb0d9d3688a6e5a3b4ebb9000d81ff6ba (patch) | |
tree | 44c9c77971b5f1ff7bd29e981ec76193118bfc37 /drivers/power/bq27x00_battery.c | |
parent | 60a1c4d41b3af91366bcb2a52b30b2050a48273e (diff) |
bq27x00_battery: Fix reporting battery temperature
Reported temperature can be also negative, so cache value in non negative
Kelvin degree.
Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
Signed-off-by: Anton Vorontsov <anton@enomsg.org>
Diffstat (limited to 'drivers/power/bq27x00_battery.c')
-rw-r--r-- | drivers/power/bq27x00_battery.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/drivers/power/bq27x00_battery.c b/drivers/power/bq27x00_battery.c index 7087d0d6a087..8ccf5d7d0add 100644 --- a/drivers/power/bq27x00_battery.c +++ b/drivers/power/bq27x00_battery.c | |||
@@ -299,7 +299,7 @@ static int bq27x00_battery_read_energy(struct bq27x00_device_info *di) | |||
299 | } | 299 | } |
300 | 300 | ||
301 | /* | 301 | /* |
302 | * Return the battery temperature in tenths of degree Celsius | 302 | * Return the battery temperature in tenths of degree Kelvin |
303 | * Or < 0 if something fails. | 303 | * Or < 0 if something fails. |
304 | */ | 304 | */ |
305 | static int bq27x00_battery_read_temperature(struct bq27x00_device_info *di) | 305 | static int bq27x00_battery_read_temperature(struct bq27x00_device_info *di) |
@@ -312,10 +312,8 @@ static int bq27x00_battery_read_temperature(struct bq27x00_device_info *di) | |||
312 | return temp; | 312 | return temp; |
313 | } | 313 | } |
314 | 314 | ||
315 | if (bq27xxx_is_chip_version_higher(di)) | 315 | if (!bq27xxx_is_chip_version_higher(di)) |
316 | temp -= 2731; | 316 | temp = 5 * temp / 2; |
317 | else | ||
318 | temp = ((temp * 5) - 5463) / 2; | ||
319 | 317 | ||
320 | return temp; | 318 | return temp; |
321 | } | 319 | } |
@@ -641,6 +639,8 @@ static int bq27x00_battery_get_property(struct power_supply *psy, | |||
641 | break; | 639 | break; |
642 | case POWER_SUPPLY_PROP_TEMP: | 640 | case POWER_SUPPLY_PROP_TEMP: |
643 | ret = bq27x00_simple_value(di->cache.temperature, val); | 641 | ret = bq27x00_simple_value(di->cache.temperature, val); |
642 | if (ret == 0) | ||
643 | val->intval -= 2731; | ||
644 | break; | 644 | break; |
645 | case POWER_SUPPLY_PROP_TIME_TO_EMPTY_NOW: | 645 | case POWER_SUPPLY_PROP_TIME_TO_EMPTY_NOW: |
646 | ret = bq27x00_simple_value(di->cache.time_to_empty, val); | 646 | ret = bq27x00_simple_value(di->cache.time_to_empty, val); |