]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/4.4.170/power-supply-olpc_battery-correct-the-temperature-units.patch
fixes for 4.19
[thirdparty/kernel/stable-queue.git] / releases / 4.4.170 / power-supply-olpc_battery-correct-the-temperature-units.patch
CommitLineData
0a67671d
GKH
1From ed54ffbe554f0902689fd6d1712bbacbacd11376 Mon Sep 17 00:00:00 2001
2From: Lubomir Rintel <lkundrak@v3.sk>
3Date: Fri, 16 Nov 2018 17:23:47 +0100
4Subject: power: supply: olpc_battery: correct the temperature units
5
6From: Lubomir Rintel <lkundrak@v3.sk>
7
8commit ed54ffbe554f0902689fd6d1712bbacbacd11376 upstream.
9
10According to [1] and [2], the temperature values are in tenths of degree
11Celsius. Exposing the Celsius value makes the battery appear on fire:
12
13 $ upower -i /org/freedesktop/UPower/devices/battery_olpc_battery
14 ...
15 temperature: 236.9 degrees C
16
17Tested on OLPC XO-1 and OLPC XO-1.75 laptops.
18
19[1] include/linux/power_supply.h
20[2] Documentation/power/power_supply_class.txt
21
22Fixes: fb972873a767 ("[BATTERY] One Laptop Per Child power/battery driver")
23Cc: stable@vger.kernel.org
24Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
25Acked-by: Pavel Machek <pavel@ucw.cz>
26Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
27Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
28
29---
30 drivers/power/olpc_battery.c | 4 ++--
31 1 file changed, 2 insertions(+), 2 deletions(-)
32
33--- a/drivers/power/olpc_battery.c
34+++ b/drivers/power/olpc_battery.c
35@@ -427,14 +427,14 @@ static int olpc_bat_get_property(struct
36 if (ret)
37 return ret;
38
39- val->intval = (s16)be16_to_cpu(ec_word) * 100 / 256;
40+ val->intval = (s16)be16_to_cpu(ec_word) * 10 / 256;
41 break;
42 case POWER_SUPPLY_PROP_TEMP_AMBIENT:
43 ret = olpc_ec_cmd(EC_AMB_TEMP, NULL, 0, (void *)&ec_word, 2);
44 if (ret)
45 return ret;
46
47- val->intval = (int)be16_to_cpu(ec_word) * 100 / 256;
48+ val->intval = (int)be16_to_cpu(ec_word) * 10 / 256;
49 break;
50 case POWER_SUPPLY_PROP_CHARGE_COUNTER:
51 ret = olpc_ec_cmd(EC_BAT_ACR, NULL, 0, (void *)&ec_word, 2);