Skip to content

Commit

Permalink
hwmon: (ina209) Handled signed registers
Browse files Browse the repository at this point in the history
The shunt voltage and current registers are signed 16-bit values so
handle them as such.

Signed-off-by: Joe Schaack <jschaack@xes-inc.com>
Reviewed-by: Aaron Sierra <asierra@xes-inc.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
  • Loading branch information
Joe Schaack authored and Guenter Roeck committed Apr 21, 2017
1 parent a02c24a commit bdaf9c4
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/hwmon/ina209.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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 */
Expand Down

0 comments on commit bdaf9c4

Please sign in to comment.