From: "Pali Rohár" <pali.rohar@gmail.com>
To: linux-kernel@vger.kernel.org
Cc: "Anton Vorontsov" <cbouatmailru@gmail.com>,
"David Woodhouse" <dwmw2@infradead.org>,
"Pali Rohár" <pali.rohar@gmail.com>
Subject: [PATCH] bq27x00_battery: Do not report nominal available capaciy if battery is not calibrated
Date: Sat, 10 Nov 2012 15:42:48 +0100 [thread overview]
Message-ID: <1352558568-30607-1-git-send-email-pali.rohar@gmail.com> (raw)
Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
---
drivers/power/bq27x00_battery.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/drivers/power/bq27x00_battery.c b/drivers/power/bq27x00_battery.c
index 5860d4d..41b3328 100644
--- a/drivers/power/bq27x00_battery.c
+++ b/drivers/power/bq27x00_battery.c
@@ -230,6 +230,14 @@ static int bq27x00_battery_read_charge(struct bq27x00_device_info *di, u8 reg)
*/
static inline int bq27x00_battery_read_nac(struct bq27x00_device_info *di)
{
+ int flags;
+ bool is_bq27500 = di->chip == BQ27500;
+ bool is_higher = bq27xxx_is_chip_version_higher(di);
+
+ flags = bq27x00_read(di, BQ27x00_REG_FLAGS, !is_bq27500);
+ if (flags >= 0 && !is_higher && (flags & BQ27000_FLAG_CI))
+ return -ENODATA;
+
return bq27x00_battery_read_charge(di, BQ27x00_REG_NAC);
}
--
1.7.10.4
next reply other threads:[~2012-11-10 14:43 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-10 14:42 Pali Rohár [this message]
2012-11-19 0:05 ` [PATCH] bq27x00_battery: Do not report nominal available capaciy if battery is not calibrated Anton Vorontsov
2012-11-19 18:43 ` Pali Rohár
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=1352558568-30607-1-git-send-email-pali.rohar@gmail.com \
--to=pali.rohar@gmail.com \
--cc=cbouatmailru@gmail.com \
--cc=dwmw2@infradead.org \
--cc=linux-kernel@vger.kernel.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