diff options
author | Len Brown <len.brown@intel.com> | 2011-03-23 02:34:18 -0400 |
---|---|---|
committer | Len Brown <len.brown@intel.com> | 2011-03-23 02:34:18 -0400 |
commit | 96e1c408ea8a556c5b51e0e7d56bd2afbfbf5fe9 (patch) | |
tree | 805d8f519ba703cbe1ebd31304a329c1048a67ff /drivers/acpi | |
parent | f7f28f7e8c42c67c4bce24415c6cd6da222a1798 (diff) | |
parent | 25be5821521640eb00b7eb219ffe59664510d073 (diff) |
Merge branch 'battery-sysfs-notifier' into release
Diffstat (limited to 'drivers/acpi')
-rw-r--r-- | drivers/acpi/battery.c | 22 |
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 | ||
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 | static int acpi_battery_add(struct acpi_device *device) | 960 | static 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 |