public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: rklein <rklein@nvidia.com>
To: Anton Vorontsov <cbouatmailru@gmail.com>
Cc: Andrew Chew <AChew@nvidia.com>, "olof@lixom.net" <olof@lixom.net>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: [PATCH 1/1] power: bq20z75: Update return value of CURRENT NOW
Date: Tue, 14 Dec 2010 17:01:25 -0800	[thread overview]
Message-ID: <1292374885.8731.3.camel@rklein-linux2> (raw)

The BQ20Z75 will return a negative value for current if the battery is
discharging and a positive value if charging. This should always be
exported
as a positive number.

Signed-off-by: Rhyland Klein <rklein@nvidia.com>
---
 drivers/power/bq20z75.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/drivers/power/bq20z75.c b/drivers/power/bq20z75.c
index 492da27..a039ea0 100644
--- a/drivers/power/bq20z75.c
+++ b/drivers/power/bq20z75.c
@@ -220,6 +220,10 @@ static int bq20z75_get_battery_property(struct
i2c_client *client,
        if (bq20z75_data[reg_offset].min_value < 0)
                ret = (s16)ret;

+       /* for current, it shoud be always positive */
+       if (psp == POWER_SUPPLY_PROP_CURRENT_NOW)
+               ret = abs(ret);
+
        if (ret >= bq20z75_data[reg_offset].min_value &&
            ret <= bq20z75_data[reg_offset].max_value) {
                val->intval = ret;


             reply	other threads:[~2010-12-15  1:01 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-15  1:01 rklein [this message]
2010-12-15  3:04 ` [PATCH 1/1] power: bq20z75: Update return value of CURRENT NOW Olof Johansson
     [not found]   ` <1292892862.12618.1.camel@rklein-linux2>
2010-12-21 23:22     ` Anton Vorontsov
2010-12-21 23:41       ` rklein

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=1292374885.8731.3.camel@rklein-linux2 \
    --to=rklein@nvidia.com \
    --cc=AChew@nvidia.com \
    --cc=cbouatmailru@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=olof@lixom.net \
    /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