public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Fabio Baltieri <fabio.baltieri@gmail.com>
To: Guenter Roeck <linux@roeck-us.net>, Jean Delvare <jdelvare@suse.de>
Cc: Lothar Felten <l-felten@ti.com>,
	lm-sensors@lm-sensors.org, linux-kernel@vger.kernel.org,
	Fabio Baltieri <fabio.baltieri@gmail.com>
Subject: [PATCH] hwmon: (ina2xx) Change register cache to signed
Date: Sat,  7 Jun 2014 21:47:01 +0100	[thread overview]
Message-ID: <1402174021-25857-1-git-send-email-fabio.baltieri@gmail.com> (raw)

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


             reply	other threads:[~2014-06-07 20:47 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-07 20:47 Fabio Baltieri [this message]
2014-06-08 20:16 ` [PATCH] hwmon: (ina2xx) Change register cache to signed Guenter Roeck
2014-06-08 20:30   ` [lm-sensors] " Guenter Roeck
2014-06-08 20:54     ` Fabio Baltieri

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1402174021-25857-1-git-send-email-fabio.baltieri@gmail.com \
    --to=fabio.baltieri@gmail.com \
    --cc=jdelvare@suse.de \
    --cc=l-felten@ti.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=lm-sensors@lm-sensors.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox