Commit 72c7b285 authored by Lubomir Rintel's avatar Lubomir Rintel Committed by Juerg Haefliger

power: supply: olpc_battery: correct the temperature units

BugLink: https://bugs.launchpad.net/bugs/1811647

commit ed54ffbe upstream.

According to [1] and [2], the temperature values are in tenths of degree
Celsius. Exposing the Celsius value makes the battery appear on fire:

  $ upower -i /org/freedesktop/UPower/devices/battery_olpc_battery
  ...
      temperature:         236.9 degrees C

Tested on OLPC XO-1 and OLPC XO-1.75 laptops.

[1] include/linux/power_supply.h
[2] Documentation/power/power_supply_class.txt

Fixes: fb972873 ("[BATTERY] One Laptop Per Child power/battery driver")
Cc: stable@vger.kernel.org
Signed-off-by: default avatarLubomir Rintel <lkundrak@v3.sk>
Acked-by: default avatarPavel Machek <pavel@ucw.cz>
Signed-off-by: default avatarSebastian Reichel <sebastian.reichel@collabora.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarJuerg Haefliger <juergh@canonical.com>
Signed-off-by: default avatarStefan Bader <stefan.bader@canonical.com>
parent d126ac19
...@@ -427,14 +427,14 @@ static int olpc_bat_get_property(struct power_supply *psy, ...@@ -427,14 +427,14 @@ static int olpc_bat_get_property(struct power_supply *psy,
if (ret) if (ret)
return ret; return ret;
val->intval = (s16)be16_to_cpu(ec_word) * 100 / 256; val->intval = (s16)be16_to_cpu(ec_word) * 10 / 256;
break; break;
case POWER_SUPPLY_PROP_TEMP_AMBIENT: case POWER_SUPPLY_PROP_TEMP_AMBIENT:
ret = olpc_ec_cmd(EC_AMB_TEMP, NULL, 0, (void *)&ec_word, 2); ret = olpc_ec_cmd(EC_AMB_TEMP, NULL, 0, (void *)&ec_word, 2);
if (ret) if (ret)
return ret; return ret;
val->intval = (int)be16_to_cpu(ec_word) * 100 / 256; val->intval = (int)be16_to_cpu(ec_word) * 10 / 256;
break; break;
case POWER_SUPPLY_PROP_CHARGE_COUNTER: case POWER_SUPPLY_PROP_CHARGE_COUNTER:
ret = olpc_ec_cmd(EC_BAT_ACR, NULL, 0, (void *)&ec_word, 2); ret = olpc_ec_cmd(EC_BAT_ACR, NULL, 0, (void *)&ec_word, 2);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment