From: Joe Schaack Date: Tue, 18 Apr 2017 12:15:50 +0000 (-0500) Subject: hwmon: (ina209) Handled signed registers X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=bdaf9c40b2d1d67617b259c59ce1858eda54b4ce;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git hwmon: (ina209) Handled signed registers The shunt voltage and current registers are signed 16-bit values so handle them as such. Signed-off-by: Joe Schaack Reviewed-by: Aaron Sierra Signed-off-by: Guenter Roeck --- diff --git a/drivers/hwmon/ina209.c b/drivers/hwmon/ina209.c index c5f20f03e0be..aa0768ce8aea 100644 --- a/drivers/hwmon/ina209.c +++ b/drivers/hwmon/ina209.c @@ -117,7 +117,7 @@ static long ina209_from_reg(const u8 reg, const u16 val) case INA209_SHUNT_VOLTAGE_POS_WARN: case INA209_SHUNT_VOLTAGE_NEG_WARN: /* LSB=10 uV. Convert to mV. */ - return DIV_ROUND_CLOSEST(val, 100); + return DIV_ROUND_CLOSEST((s16)val, 100); case INA209_BUS_VOLTAGE: case INA209_BUS_VOLTAGE_MAX_PEAK: @@ -146,7 +146,7 @@ static long ina209_from_reg(const u8 reg, const u16 val) case INA209_CURRENT: /* LSB=1 mA (selected). Is in mA */ - return val; + return (s16)val; } /* programmer goofed */