All of lore.kernel.org
 help / color / mirror / Atom feed
* [lm-sensors] [PATCH] hwmon: (ina2xx) Change register cache to signed
@ 2014-06-07 20:47 ` Fabio Baltieri
  0 siblings, 0 replies; 8+ messages in thread
From: Fabio Baltieri @ 2014-06-07 20:47 UTC (permalink / raw)
  To: Guenter Roeck, Jean Delvare
  Cc: Lothar Felten, lm-sensors, linux-kernel, Fabio Baltieri

All devices supported by the ina2xx driver are bidirectional and reports
the measured value as a signed 16 bit, but the current driver
implementation caches the number as an u16, leading to an incorrect sign
extension when reporting to the userspace in ina2xx_get_value().

This patch fixes the problem by using a s16 instead, and has been tested
on an INA219.

Signed-off-by: Fabio Baltieri <fabio.baltieri@gmail.com>
---
 drivers/hwmon/ina2xx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/hwmon/ina2xx.c b/drivers/hwmon/ina2xx.c
index 93d26e8..d994280 100644
--- a/drivers/hwmon/ina2xx.c
+++ b/drivers/hwmon/ina2xx.c
@@ -86,7 +86,7 @@ struct ina2xx_data {
 	unsigned long last_updated;
 
 	int kind;
-	u16 regs[INA2XX_MAX_REGISTERS];
+	s16 regs[INA2XX_MAX_REGISTERS];
 };
 
 static const struct ina2xx_config ina2xx_config[] = {
-- 
1.8.4


_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2014-06-08 20:54 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-07 20:47 [lm-sensors] [PATCH] hwmon: (ina2xx) Change register cache to signed Fabio Baltieri
2014-06-07 20:47 ` Fabio Baltieri
2014-06-08 20:16 ` [lm-sensors] " Guenter Roeck
2014-06-08 20:16   ` Guenter Roeck
2014-06-08 20:30   ` [lm-sensors] " Guenter Roeck
2014-06-08 20:30     ` Guenter Roeck
2014-06-08 20:54     ` Fabio Baltieri
2014-06-08 20:54       ` Fabio Baltieri

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.