linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] power: supply: bq27xxx_battery: Notify about all battery changes
@ 2020-05-25 14:11 Krzysztof Kozlowski
  2020-05-25 14:12 ` [PATCH 2/2] power: supply: bq27xxx_battery: Notify about voltage and current changes Krzysztof Kozlowski
  2020-05-27  1:24 ` [PATCH 1/2] power: supply: bq27xxx_battery: Notify about all battery changes Andrew F. Davis
  0 siblings, 2 replies; 7+ messages in thread
From: Krzysztof Kozlowski @ 2020-05-25 14:11 UTC (permalink / raw)
  To: Andrew F. Davis, Pali Rohár, Sebastian Reichel,
	Krzysztof Kozlowski, linux-kernel, linux-pm
  Cc: Krzysztof Kozlowski

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.

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;
 }
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-06-16 11:57 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-25 14:11 [PATCH 1/2] power: supply: bq27xxx_battery: Notify about all battery changes Krzysztof Kozlowski
2020-05-25 14:12 ` [PATCH 2/2] power: supply: bq27xxx_battery: Notify about voltage and current changes Krzysztof Kozlowski
2020-05-27  1:24 ` [PATCH 1/2] power: supply: bq27xxx_battery: Notify about all battery changes Andrew F. Davis
2020-05-27  7:22   ` Krzysztof Kozlowski
2020-05-27  7:30     ` Krzysztof Kozlowski
2020-06-16 10:52   ` Pavel Machek
2020-06-16 11:57     ` Krzysztof Kozlowski

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).