Commit 25be5821521640eb00b7eb219ffe59664510d073
Committed by
Len Brown
1 parent
521cb40b0c
Exists in
master
and in
39 other branches
ACPI battery: fribble sysfs files from a resume notifier
Commit da8aeb92 re-poked the battery on resume, but Linus reports that it broke his eee and partially reverted it in b23fffd7. Unfortunately this also results in my x201s giving crack values until the sysfs files are poked again. In the revert message, it was suggested that we poke it from a PM notifier, so let's do that. With this in place, I haven't noticed the units going nutty on my gnome-power-manager across a dozen suspends or so... Signed-off-by: Kyle McMartin <kyle@redhat.com> Acked-by: Rafael J. Wysocki <rjw@sisk.pl> Signed-off-by: Len Brown <len.brown@intel.com>
Showing 1 changed file with 22 additions and 0 deletions Side-by-side Diff
drivers/acpi/battery.c
... | ... | @@ -33,6 +33,7 @@ |
33 | 33 | #include <linux/async.h> |
34 | 34 | #include <linux/dmi.h> |
35 | 35 | #include <linux/slab.h> |
36 | +#include <linux/suspend.h> | |
36 | 37 | |
37 | 38 | #ifdef CONFIG_ACPI_PROCFS_POWER |
38 | 39 | #include <linux/proc_fs.h> |
... | ... | @@ -102,6 +103,7 @@ |
102 | 103 | struct mutex lock; |
103 | 104 | struct power_supply bat; |
104 | 105 | struct acpi_device *device; |
106 | + struct notifier_block pm_nb; | |
105 | 107 | unsigned long update_time; |
106 | 108 | int rate_now; |
107 | 109 | int capacity_now; |
... | ... | @@ -940,6 +942,21 @@ |
940 | 942 | power_supply_changed(&battery->bat); |
941 | 943 | } |
942 | 944 | |
945 | +static int battery_notify(struct notifier_block *nb, | |
946 | + unsigned long mode, void *_unused) | |
947 | +{ | |
948 | + struct acpi_battery *battery = container_of(nb, struct acpi_battery, | |
949 | + pm_nb); | |
950 | + switch (mode) { | |
951 | + case PM_POST_SUSPEND: | |
952 | + sysfs_remove_battery(battery); | |
953 | + sysfs_add_battery(battery); | |
954 | + break; | |
955 | + } | |
956 | + | |
957 | + return 0; | |
958 | +} | |
959 | + | |
943 | 960 | static int acpi_battery_add(struct acpi_device *device) |
944 | 961 | { |
945 | 962 | int result = 0; |
... | ... | @@ -972,6 +989,10 @@ |
972 | 989 | #endif |
973 | 990 | kfree(battery); |
974 | 991 | } |
992 | + | |
993 | + battery->pm_nb.notifier_call = battery_notify; | |
994 | + register_pm_notifier(&battery->pm_nb); | |
995 | + | |
975 | 996 | return result; |
976 | 997 | } |
977 | 998 | |
... | ... | @@ -982,6 +1003,7 @@ |
982 | 1003 | if (!device || !acpi_driver_data(device)) |
983 | 1004 | return -EINVAL; |
984 | 1005 | battery = acpi_driver_data(device); |
1006 | + unregister_pm_notifier(&battery->pm_nb); | |
985 | 1007 | #ifdef CONFIG_ACPI_PROCFS_POWER |
986 | 1008 | acpi_battery_remove_fs(device); |
987 | 1009 | #endif |