]> git.baikalelectronics.ru Git - kernel.git/commit
hwmon: (ina2xx) Cast to s16 on shunt and current regs
authorFabio Baltieri <fabio.baltieri@gmail.com>
Sun, 8 Jun 2014 21:06:24 +0000 (22:06 +0100)
committerGuenter Roeck <linux@roeck-us.net>
Thu, 12 Jun 2014 15:36:18 +0000 (08:36 -0700)
commit4a8e273660edbca9a510ee92b7e1331bdb5b5c33
tree5a820dc1926e81b18ed357f94d3a1bbcb9d59d32
parent18edba0ef3625e1d6268090340c150575db44ef6
hwmon: (ina2xx) Cast to s16 on shunt and current regs

All devices supported by ina2xx are bidirectional and report the
measured shunt voltage and power values as a signed 16 bit, but the
current driver implementation caches all registers as u16, leading
to an incorrect sign extension when reporting to userspace in
ina2xx_get_value().

This patch fixes the problem by casting the signed registers to s16.
Tested on an INA219.

Signed-off-by: Fabio Baltieri <fabio.baltieri@gmail.com>
Cc: stable@vger.kernel.org # 3.10+
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
drivers/hwmon/ina2xx.c