diff options
author | Hans de Goede <hdegoede@redhat.com> | 2017-04-14 20:32:48 +0200 |
---|---|---|
committer | Sebastian Reichel <sre@kernel.org> | 2017-05-01 12:37:21 +0200 |
commit | 2814913c3136b41084a896c90062bd9b87672dff (patch) | |
tree | ae1956fb3969362f041d54f7cc0974780091acb5 /drivers/power/supply | |
parent | power: supply: max17042_battery: Use sign_extend32 instead of DIY code (diff) | |
download | linux-2814913c3136b41084a896c90062bd9b87672dff.tar.xz linux-2814913c3136b41084a896c90062bd9b87672dff.zip |
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/supply')
-rw-r--r-- | drivers/power/supply/max17042_battery.c | 4 |
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; |