aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/battery.c
diff options
context:
space:
mode:
authorKyle McMartin <kyle@redhat.com>2011-03-22 16:19:50 -0400
committerLen Brown <len.brown@intel.com>2011-03-22 23:30:31 -0400
commit25be5821521640eb00b7eb219ffe59664510d073 (patch)
treeb4bc6beeedb4b19dad4b147a1024d4c59cd33729 /drivers/acpi/battery.c
parent521cb40b0c44418a4fd36dc633f575813d59a43d (diff)
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>
Diffstat (limited to 'drivers/acpi/battery.c')
-rw-r--r--drivers/acpi/battery.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
index ac1a599f5147..fcc13ac0aa18 100644
--- a/drivers/acpi/battery.c
+++ b/drivers/acpi/battery.c
@@ -33,6 +33,7 @@
33#include <linux/async.h> 33#include <linux/async.h>
34#include <linux/dmi.h> 34#include <linux/dmi.h>
35#include <linux/slab.h> 35#include <linux/slab.h>
36#include <linux/suspend.h>
36 37
37#ifdef CONFIG_ACPI_PROCFS_POWER 38#ifdef CONFIG_ACPI_PROCFS_POWER
38#include <linux/proc_fs.h> 39#include <linux/proc_fs.h>
@@ -102,6 +103,7 @@ struct acpi_battery {
102 struct mutex lock; 103 struct mutex lock;
103 struct power_supply bat; 104 struct power_supply bat;
104 struct acpi_device *device; 105 struct acpi_device *device;
106 struct notifier_block pm_nb;
105 unsigned long update_time; 107 unsigned long update_time;
106 int rate_now; 108 int rate_now;
107 int capacity_now; 109 int capacity_now;
@@ -940,6 +942,21 @@ static void acpi_battery_notify(struct acpi_device *device, u32 event)
940 power_supply_changed(&battery->bat); 942 power_supply_changed(&battery->bat);
941} 943}
942 944
945static 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
943static int acpi_battery_add(struct acpi_device *device) 960static int acpi_battery_add(struct acpi_device *device)
944{ 961{
945 int result = 0; 962 int result = 0;
@@ -972,6 +989,10 @@ static int acpi_battery_add(struct acpi_device *device)
972#endif 989#endif
973 kfree(battery); 990 kfree(battery);
974 } 991 }
992
993 battery->pm_nb.notifier_call = battery_notify;
994 register_pm_notifier(&battery->pm_nb);
995
975 return result; 996 return result;
976} 997}
977 998
@@ -982,6 +1003,7 @@ static int acpi_battery_remove(struct acpi_device *device, int type)
982 if (!device || !acpi_driver_data(device)) 1003 if (!device || !acpi_driver_data(device))
983 return -EINVAL; 1004 return -EINVAL;
984 battery = acpi_driver_data(device); 1005 battery = acpi_driver_data(device);
1006 unregister_pm_notifier(&battery->pm_nb);
985#ifdef CONFIG_ACPI_PROCFS_POWER 1007#ifdef CONFIG_ACPI_PROCFS_POWER
986 acpi_battery_remove_fs(device); 1008 acpi_battery_remove_fs(device);
987#endif 1009#endif