From: "Pali Rohár" <pali.rohar@gmail.com>
To: Anton Vorontsov <cbouatmailru@gmail.com>
Cc: "David Woodhouse" <dwmw2@infradead.org>,
linux-kernel@vger.kernel.org, "Pali Rohár" <pali.rohar@gmail.com>
Subject: [PATCH] bq27x00_battery: Fix reporting battery temperature
Date: Sat, 2 Feb 2013 11:06:09 +0100 [thread overview]
Message-ID: <1359799569-5322-1-git-send-email-pali.rohar@gmail.com> (raw)
Reported temperature can be also negative, so cache value in non negative Kelvin degree.
Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
---
drivers/power/bq27x00_battery.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/power/bq27x00_battery.c b/drivers/power/bq27x00_battery.c
index 36b34ef..4f39dd8 100644
--- a/drivers/power/bq27x00_battery.c
+++ b/drivers/power/bq27x00_battery.c
@@ -299,7 +299,7 @@ static int bq27x00_battery_read_energy(struct bq27x00_device_info *di)
}
/*
- * Return the battery temperature in tenths of degree Celsius
+ * Return the battery temperature in tenths of degree Kelvin
* Or < 0 if something fails.
*/
static int bq27x00_battery_read_temperature(struct bq27x00_device_info *di)
@@ -312,10 +312,8 @@ static int bq27x00_battery_read_temperature(struct bq27x00_device_info *di)
return temp;
}
- if (bq27xxx_is_chip_version_higher(di))
- temp -= 2731;
- else
- temp = ((temp * 5) - 5463) / 2;
+ if (!bq27xxx_is_chip_version_higher(di))
+ temp = 5 * temp / 2;
return temp;
}
@@ -642,6 +640,8 @@ static int bq27x00_battery_get_property(struct power_supply *psy,
break;
case POWER_SUPPLY_PROP_TEMP:
ret = bq27x00_simple_value(di->cache.temperature, val);
+ if (ret == 0)
+ val->intval -= 2731;
break;
case POWER_SUPPLY_PROP_TIME_TO_EMPTY_NOW:
ret = bq27x00_simple_value(di->cache.time_to_empty, val);
--
1.7.10.4
next reply other threads:[~2013-02-02 10:06 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-02 10:06 Pali Rohár [this message]
2013-02-03 3:44 ` Anton Vorontsov
2013-02-03 20:01 ` Pali Rohár
2013-02-03 20:05 ` Anton Vorontsov
2013-02-06 17:56 ` Pali Rohár
2013-02-09 1:57 ` Anton Vorontsov
2013-02-09 11:02 ` Pali Rohár
2013-02-16 21:32 ` Anton Vorontsov
2013-03-28 16:42 ` [PATCH] power: rx51_battery: Fix reporting temperature Pali Rohár
2013-04-08 10:50 ` Pali Rohár
2013-04-17 1:33 ` Anton Vorontsov
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=1359799569-5322-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
Powered by JetHome