Skip to contentSkip to conversation

power: supply: bq27xxx_battery: Notify also about status changes

PATCH Superseded Krzysztof Kozlowski 2 participants 3 messages Apr 26, 2019

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 power: supply: bq27xxx_battery: Notify also about status changes

User-space might be interested in receiving uevents when the charging starts/stops or if conditions of battery changes (e.g. over-temperature). Notify about changes in battery also when the flags change, not only SoC.

---
 drivers/power/supply/bq27xxx_battery.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/power/supply/bq27xxx_battery.c +2 -1
index 29b3a4056865..cb9306160c14 100644
@@ -1612,7 +1612,8 @@ void bq27xxx_battery_update(struct bq27xxx_device_info *di)
 			di->charge_design_full = bq27xxx_battery_read_dcap(di);
 	}
 
-	if (di->cache.capacity != cache.capacity)
+	if ((di->cache.capacity != cache.capacity) || \
+	    (di->cache.flags != cache.flags))
 		power_supply_changed(di->bat);
 
 	if (memcmp(&di->cache, &cache, sizeof(cache)) != 0)
Signature · 1 line
2.7.4
#1 lore raw
Quoted 4 lines · On Friday 26 April 2019 11:26:48 Krzysztof Kozlowski wrote:

User-space might be interested in receiving uevents when the charging starts/stops or if conditions of battery changes (e.g. over-temperature). Notify about changes in battery also when the flags change, not only SoC.

This looks like a good idea.

Quoted 10 lines
---
 drivers/power/supply/bq27xxx_battery.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/power/supply/bq27xxx_battery.c +0 -0
index 29b3a4056865..cb9306160c14 100644

drivers/power/supply/bq27xxx_battery.c void bq27xxx_battery_update(struct bq27xxx_device_info *di) · line 1615

Quoted 5 lines
drivers/power/supply/bq27xxx_battery.c +1 -1
@@ -1612,7 +1612,8 @@ void bq27xxx_battery_update(struct bq27xxx_device_info *di)
 			di->charge_design_full = bq27xxx_battery_read_dcap(di);
 	}
 
-	if (di->cache.capacity != cache.capacity)
+	if ((di->cache.capacity != cache.capacity) || \

^^
You have there an extra backslash

Quoted 4 lines
drivers/power/supply/bq27xxx_battery.c +1 -0
+	    (di->cache.flags != cache.flags))
 		power_supply_changed(di->bat);
 
 	if (memcmp(&di->cache, &cache, sizeof(cache)) != 0)
Signature · 2 lines
Pali Rohár
[email protected]
#2 lore raw
Quoted 22 lines · Pali Rohár
Quoted 4 lines · On Friday 26 April 2019 11:26:48 Krzysztof Kozlowski wrote:

User-space might be interested in receiving uevents when the charging starts/stops or if conditions of battery changes (e.g. over-temperature). Notify about changes in battery also when the flags change, not only SoC.

This looks like a good idea.

Quoted 13 lines
---
 drivers/power/supply/bq27xxx_battery.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/power/supply/bq27xxx_battery.c +0 -0
index 29b3a4056865..cb9306160c14 100644
@@ -1612,7 +1612,8 @@ void bq27xxx_battery_update(struct bq27xxx_device_info *di)
                      di->charge_design_full = bq27xxx_battery_read_dcap(di);
      }
 
Quoted 4 lines

drivers/power/supply/bq27xxx_battery.c void bq27xxx_battery_update(struct bq27xxx_device_info *di) · line 1615

Quoted 2 lines
drivers/power/supply/bq27xxx_battery.c +1 -1
-     if (di->cache.capacity != cache.capacity)
+     if ((di->cache.capacity != cache.capacity) || \

^^
You have there an extra backslash

Indeed, Thanks! Let me send v2.

Best regards,
Krzysztof