lkml.org 
[lkml]   [2017]   [May]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 5/5] power: supply: bq27xxx: Correct supply status with current draw
Hi!

> The status reported directly by the battery controller is not always
> reliable and should be corrected based on the current draw information.
>
> This implements such a correction with a dedicated function, called
> when retrieving the supply status.
>

> @@ -1182,6 +1196,8 @@ static int bq27xxx_battery_status(struct bq27xxx_device_info *di,
> else
> status = POWER_SUPPLY_STATUS_DISCHARGING;
> } else {
> + curr = (int)((s16)curr) * 1000;

Umm.

> @@ -1190,6 +1206,18 @@ static int bq27xxx_battery_status(struct bq27xxx_device_info *di,
> status = POWER_SUPPLY_STATUS_CHARGING;
> }
>
> +
> + if (curr == 0 && status != POWER_SUPPLY_STATUS_NOT_CHARGING)
> + status = POWER_SUPPLY_STATUS_FULL;
> +
> + if (status == POWER_SUPPLY_STATUS_FULL) {
> + /* Drawing or providing current when full */
> + if (curr > 0)
> + status = POWER_SUPPLY_STATUS_CHARGING;
> + else if (curr < 0)
> + status = POWER_SUPPLY_STATUS_DISCHARGING;
> + }

Are you sure this works? On N900, we normally see small currents to/from "full" battery.

Should the test be for absolute_value(curr) < something rather than for == 0?

What hw did you test it on?
Pavel
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

\
 
 \ /
  Last update: 2017-05-28 21:17    [W:0.170 / U:0.096 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site