summaryrefslogtreecommitdiff
path: root/drivers/power
diff options
context:
space:
mode:
authorHans de Goede <hdegoede@redhat.com>2017-04-14 21:32:48 +0300
committerSebastian Reichel <sre@kernel.org>2017-05-01 13:37:21 +0300
commit2814913c3136b41084a896c90062bd9b87672dff (patch)
treeae1956fb3969362f041d54f7cc0974780091acb5 /drivers/power
parentc67c06939ee4a24fcad1235dd9632153533fdd4d (diff)
downloadlinux-2814913c3136b41084a896c90062bd9b87672dff.tar.xz
power: supply: max17047_battery: The temp alert values are 8-bit 2's complement
The temp alert values are 8-bit 2's complement, so sign-extend them before reporting them back to the caller. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Reviewed-by: Krzysztof Kozlowski <krzk@kernel.org> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
Diffstat (limited to 'drivers/power')
-rw-r--r--drivers/power/supply/max17042_battery.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/power/supply/max17042_battery.c b/drivers/power/supply/max17042_battery.c
index 790dfa9d0a2e..a51b2965cd5c 100644
--- a/drivers/power/supply/max17042_battery.c
+++ b/drivers/power/supply/max17042_battery.c
@@ -270,14 +270,14 @@ static int max17042_get_property(struct power_supply *psy,
if (ret < 0)
return ret;
/* LSB is Alert Minimum. In deci-centigrade */
- val->intval = (data & 0xff) * 10;
+ val->intval = sign_extend32(data & 0xff, 7) * 10;
break;
case POWER_SUPPLY_PROP_TEMP_ALERT_MAX:
ret = regmap_read(map, MAX17042_TALRT_Th, &data);
if (ret < 0)
return ret;
/* MSB is Alert Maximum. In deci-centigrade */
- val->intval = (data >> 8) * 10;
+ val->intval = sign_extend32(data >> 8, 7) * 10;
break;
case POWER_SUPPLY_PROP_TEMP_MIN:
val->intval = chip->pdata->temp_min;