lkml.org 
[lkml]   [2020]   [May]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH 1/2] power: supply: bq27xxx_battery: Notify about all battery changes
From
Date
On 5/25/20 10:11 AM, Krzysztof Kozlowski wrote:
> All battery related data could be important for user-space. For example
> time-to-full could be shown to user on the screen or health could be
> monitored for any issues. Instead of comparing few selected old/new
> values, just check if anything changed in the cache.
>


At least some value will change every time we poll the battery, are we
okay with having power_supply_changed() called every time?

Andrew


> Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
> ---
> drivers/power/supply/bq27xxx_battery.c | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/power/supply/bq27xxx_battery.c b/drivers/power/supply/bq27xxx_battery.c
> index 942c92127b6d..33c26d42cd02 100644
> --- a/drivers/power/supply/bq27xxx_battery.c
> +++ b/drivers/power/supply/bq27xxx_battery.c
> @@ -1612,12 +1612,10 @@ void bq27xxx_battery_update(struct bq27xxx_device_info *di)
> di->charge_design_full = bq27xxx_battery_read_dcap(di);
> }
>
> - if ((di->cache.capacity != cache.capacity) ||
> - (di->cache.flags != cache.flags))
> + if (memcmp(&di->cache, &cache, sizeof(cache)) != 0) {
> power_supply_changed(di->bat);
> -
> - if (memcmp(&di->cache, &cache, sizeof(cache)) != 0)
> di->cache = cache;
> + }
>
> di->last_update = jiffies;
> }
>

\
 
 \ /
  Last update: 2020-05-27 03:25    [W:0.066 / U:6.324 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site