Skip to content

Commit 98b0cf2

Browse files
Wer-Wolfrafaeljw
authored andcommitted
ACPI: battery: Call power_supply_changed() when adding hooks
If a battery hook is added to a battery, userspace software is not informed that the available properties of the battery might have changed. This for example causes upower to react slowly if a new battery hook is added during runtime. Fix this by calling power_supply_changed() if a battery hook was successfully added/removed. Tested on a Dell Inspiron 3505. Signed-off-by: Armin Wolf <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent b7b275e commit 98b0cf2

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

drivers/acpi/battery.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -696,7 +696,8 @@ static void __battery_hook_unregister(struct acpi_battery_hook *hook, int lock)
696696
if (lock)
697697
mutex_lock(&hook_mutex);
698698
list_for_each_entry(battery, &acpi_battery_list, list) {
699-
hook->remove_battery(battery->bat);
699+
if (!hook->remove_battery(battery->bat))
700+
power_supply_changed(battery->bat);
700701
}
701702
list_del(&hook->list);
702703
if (lock)
@@ -735,6 +736,8 @@ void battery_hook_register(struct acpi_battery_hook *hook)
735736
__battery_hook_unregister(hook, 0);
736737
goto end;
737738
}
739+
740+
power_supply_changed(battery->bat);
738741
}
739742
pr_info("new extension: %s\n", hook->name);
740743
end:

0 commit comments

Comments
 (0)