mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-28 09:31:14 +00:00
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>
This commit is contained in:
parent
c67c06939e
commit
2814913c31
1 changed files with 2 additions and 2 deletions
|
@ -270,14 +270,14 @@ static int max17042_get_property(struct power_supply *psy,
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
/* LSB is Alert Minimum. In deci-centigrade */
|
/* LSB is Alert Minimum. In deci-centigrade */
|
||||||
val->intval = (data & 0xff) * 10;
|
val->intval = sign_extend32(data & 0xff, 7) * 10;
|
||||||
break;
|
break;
|
||||||
case POWER_SUPPLY_PROP_TEMP_ALERT_MAX:
|
case POWER_SUPPLY_PROP_TEMP_ALERT_MAX:
|
||||||
ret = regmap_read(map, MAX17042_TALRT_Th, &data);
|
ret = regmap_read(map, MAX17042_TALRT_Th, &data);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
/* MSB is Alert Maximum. In deci-centigrade */
|
/* MSB is Alert Maximum. In deci-centigrade */
|
||||||
val->intval = (data >> 8) * 10;
|
val->intval = sign_extend32(data >> 8, 7) * 10;
|
||||||
break;
|
break;
|
||||||
case POWER_SUPPLY_PROP_TEMP_MIN:
|
case POWER_SUPPLY_PROP_TEMP_MIN:
|
||||||
val->intval = chip->pdata->temp_min;
|
val->intval = chip->pdata->temp_min;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue