提交 2814913c 编写于 作者: H Hans de Goede 提交者: Sebastian Reichel

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: NHans de Goede <hdegoede@redhat.com>
Reviewed-by: NKrzysztof Kozlowski <krzk@kernel.org>
Signed-off-by: NSebastian Reichel <sebastian.reichel@collabora.co.uk>
上级 c67c0693
......@@ -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;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册