Re: [PATCH] bq27x00_battery: Fix reporting battery temperature

From: Anton Vorontsov
Date: Fri Feb 08 2013 - 21:01:07 EST


On Wed, Feb 06, 2013 at 06:56:34PM +0100, Pali RohÃr wrote:
[...]
> > * 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
[...]
> bq27x00_battery reporting "POWER_SUPPLY_TEMP=2700"
> and rx51_battery reporting "POWER_SUPPLY_TEMP=3590"
[...]
> Subject: [PATCH] bq27x00_battery: Report temperature in 1/100 degree Celsius

Hm. The documentation says tenth (1/10) degrees, and you even restate it
in the commit message. But the subject, and your example seem to prove
that you still report it in 1/100 of Celsius.

Unless your phone was on fire during the time you took the values, I tend
to think the patch needs to be fixed. :-)

Thanks,
Anton

> * 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@xxxxxxxxx>
> ---
> 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@xxxxxxxxx
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/