From: "Pali Rohár" <pali.rohar@gmail.com>
To: Anton Vorontsov <anton@enomsg.org>
Cc: David Woodhouse <dwmw2@infradead.org>, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] bq27x00_battery: Fix reporting battery temperature
Date: Wed, 6 Feb 2013 18:56:34 +0100 [thread overview]
Message-ID: <201302061856.35366@pali> (raw)
In-Reply-To: <20130203200557.GA15430@lizard.gateway.2wire.net>
[-- Attachment #1: Type: Text/Plain, Size: 3112 bytes --]
On Sunday 03 February 2013 21:05:57 Anton Vorontsov wrote:
> On Sun, Feb 03, 2013 at 09:01:54PM +0100, Pali Rohár wrote:
> > On Sunday 03 February 2013 04:44:51 Anton Vorontsov wrote:
> > > On Sat, Feb 02, 2013 at 11:06:09AM +0100, Pali Rohár wrote:
> > > > Reported temperature can be also negative, so cache
> > > > value in non negative Kelvin degree.
> > > >
> > > > Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
> > > > ---
> > >
> > > Applied, thanks!
> >
> > Now I looked at bq27x00_battery and rx51_battery drivers and
> > I see that both drivers reporting temperature in different
> > units. bq27x00_battery in 1/10 °C and rx51_battery in 1/100
> > °C. What is correct degree for kernel power power supply
> > API? Maybe other kernel drivers have different units too...
> > Note that my above patch did not changed anything units,
> > only fixed reporting (possible) negative temperature.
>
> Per Documentation/power/power_supply_class.txt and
> power_supply.h:
>
> /*
> * All voltages, currents, charges, energies, time and
> temperatures in uV, * µA, µAh, µWh, seconds and tenths of
> degree Celsius unless otherwise * stated. It's driver's job
> to convert its raw values to units in which * this class
> operates.
> */
>
> Feel free to fix the offending drivers.
>
> Thanks,
>
> Anton
Ok, here is small patch which fixing it in bq27x00_battery driver.
Tested on Nokia N900 with patched 3.8-rc3 kernel.
bq27x00_battery reporting "POWER_SUPPLY_TEMP=2700"
and rx51_battery reporting "POWER_SUPPLY_TEMP=3590"
From 43a99615d6d7375770736303f1e000f3d85d75cb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pali=20Roh=C3=A1r?= <pali.rohar@gmail.com>
Date: Sun, 3 Feb 2013 22:06:20 +0100
Subject: [PATCH] bq27x00_battery: Report temperature in 1/100 degree Celsius
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
* Documentation/power/power_supply_class.txt say that temperature must be reported in tenths of degree
Celsius
Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
---
drivers/power/bq27x00_battery.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/drivers/power/bq27x00_battery.c b/drivers/power/bq27x00_battery.c
index 5b077af..482755f 100644
--- a/drivers/power/bq27x00_battery.c
+++ b/drivers/power/bq27x00_battery.c
@@ -312,8 +312,10 @@ static int bq27x00_battery_read_temperature(struct bq27x00_device_info *di)
return temp;
}
- if (!bq27xxx_is_chip_version_higher(di))
- temp = 5 * temp / 2;
+ if (bq27xxx_is_chip_version_higher(di))
+ temp *= 10;
+ else
+ temp *= 25;
return temp;
}
@@ -640,7 +642,7 @@ static int bq27x00_battery_get_property(struct power_supply *psy,
case POWER_SUPPLY_PROP_TEMP:
ret = bq27x00_simple_value(di->cache.temperature, val);
if (ret == 0)
- val->intval -= 2731;
+ val->intval -= 27310;
break;
case POWER_SUPPLY_PROP_TIME_TO_EMPTY_NOW:
ret = bq27x00_simple_value(di->cache.time_to_empty, val);
--
1.7.10.4
--
Pali Rohár
pali.rohar@gmail.com
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 198 bytes --]
next prev parent reply other threads:[~2013-02-06 17:56 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-02 10:06 [PATCH] bq27x00_battery: Fix reporting battery temperature Pali Rohár
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 [this message]
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=201302061856.35366@pali \
--to=pali.rohar@gmail.com \
--cc=anton@enomsg.org \
--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;
as well as URLs for NNTP newsgroup(s).