From: Guenter Roeck <linux@roeck-us.net>
To: Fabio Baltieri <fabio.baltieri@gmail.com>
Cc: linux-kernel@vger.kernel.org, Lothar Felten <l-felten@ti.com>,
lm-sensors@lm-sensors.org
Subject: Re: [lm-sensors] [PATCH] hwmon: (ina2xx) Change register cache to signed
Date: Sun, 8 Jun 2014 13:30:07 -0700 [thread overview]
Message-ID: <20140608203007.GA6265@roeck-us.net> (raw)
In-Reply-To: <20140608201600.GA30953@roeck-us.net>
On Sun, Jun 08, 2014 at 01:16:00PM -0700, Guenter Roeck wrote:
> On Sat, Jun 07, 2014 at 09:47:01PM +0100, Fabio Baltieri wrote:
> > 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>
>
> Applied.
>
Actually, no, this won't work. The statement above is only correct for current
and shunt voltage measurements, but not for power measurements and not for bus
voltage measurements. Changing the register to s16 won't help; conversion needs
to be done in ina2xx_get_value() for shunt voltage and current measurement only.
Otherwise we just move the bug from current/shunt voltage measurements to
power / bus voltage measurements.
Even more interesting, the power is supposed to be the product of Bus voltage
and current, and the latter can be negative. However, the power register
description does not suggest that the upper bit would be a sign bit. So there
is some discrepancy in the datasheet, and we'll need some real-world data to
understand if the upper power bit is signed or not.
Guenter
next prev parent reply other threads:[~2014-06-08 20:30 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-07 20:47 [PATCH] hwmon: (ina2xx) Change register cache to signed Fabio Baltieri
2014-06-08 20:16 ` Guenter Roeck
2014-06-08 20:30 ` Guenter Roeck [this message]
2014-06-08 20:54 ` [lm-sensors] " 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=20140608203007.GA6265@roeck-us.net \
--to=linux@roeck-us.net \
--cc=fabio.baltieri@gmail.com \
--cc=l-felten@ti.com \
--cc=linux-kernel@vger.kernel.org \
--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