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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 9 Jul 2014 18:18:26 +0000 (11:18 -0700)
commit15a446b98f735f427927a251e82fed0a5a59c9ee
tree4afe42a8f27da84194ed3ac19632bd4b3b5b4120
parentcaa1bc98057da9435a67aa6e508469b4b0238615
hwmon: (ina2xx) Cast to s16 on shunt and current regs

commit c0214f98943b1fe43f7be61b7782b0c8f0836f28 upstream.

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>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/hwmon/ina2xx.c