aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafael J. Wysocki <rjw@sisk.pl>2011-02-15 15:22:24 -0500
committerRafael J. Wysocki <rjw@sisk.pl>2011-03-14 19:43:16 -0400
commit6831c6edc7b272a08dd2a6c71bb183a48fe98ae6 (patch)
treefc3ef253f12bd9f2d211271c09a5475ed19b18b0
parente8665002477f0278f84f898145b1f141ba26ee26 (diff)
PM: Drop pm_flags that is not necessary
The variable pm_flags is used to prevent APM from being enabled along with ACPI, which would lead to problems. However, acpi_init() is always called before apm_init() and after acpi_init() has returned, it is known whether or not ACPI will be used. Namely, if acpi_disabled is not set after acpi_init() has returned, this means that ACPI is enabled. Thus, it is sufficient to check acpi_disabled in apm_init() to prevent APM from being enabled in parallel with ACPI. Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl> Acked-by: Len Brown <len.brown@intel.com>
-rw-r--r--arch/x86/kernel/apm_32.c5
-rw-r--r--drivers/acpi/bus.c22
-rw-r--r--include/linux/pm.h9
-rw-r--r--include/linux/suspend.h6
-rw-r--r--kernel/power/main.c13
5 files changed, 7 insertions, 48 deletions
diff --git a/arch/x86/kernel/apm_32.c b/arch/x86/kernel/apm_32.c
index 0e4f24c2a746..15f47f741983 100644
--- a/arch/x86/kernel/apm_32.c
+++ b/arch/x86/kernel/apm_32.c
@@ -227,6 +227,7 @@
227#include <linux/suspend.h> 227#include <linux/suspend.h>
228#include <linux/kthread.h> 228#include <linux/kthread.h>
229#include <linux/jiffies.h> 229#include <linux/jiffies.h>
230#include <linux/acpi.h>
230 231
231#include <asm/system.h> 232#include <asm/system.h>
232#include <asm/uaccess.h> 233#include <asm/uaccess.h>
@@ -2331,12 +2332,11 @@ static int __init apm_init(void)
2331 apm_info.disabled = 1; 2332 apm_info.disabled = 1;
2332 return -ENODEV; 2333 return -ENODEV;
2333 } 2334 }
2334 if (pm_flags & PM_ACPI) { 2335 if (!acpi_disabled) {
2335 printk(KERN_NOTICE "apm: overridden by ACPI.\n"); 2336 printk(KERN_NOTICE "apm: overridden by ACPI.\n");
2336 apm_info.disabled = 1; 2337 apm_info.disabled = 1;
2337 return -ENODEV; 2338 return -ENODEV;
2338 } 2339 }
2339 pm_flags |= PM_APM;
2340 2340
2341 /* 2341 /*
2342 * Set up the long jump entry point to the APM BIOS, which is called 2342 * Set up the long jump entry point to the APM BIOS, which is called
@@ -2428,7 +2428,6 @@ static void __exit apm_exit(void)
2428 kthread_stop(kapmd_task); 2428 kthread_stop(kapmd_task);
2429 kapmd_task = NULL; 2429 kapmd_task = NULL;
2430 } 2430 }
2431 pm_flags &= ~PM_APM;
2432} 2431}
2433 2432
2434module_init(apm_init); 2433module_init(apm_init);
diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c
index 973b0709972c..9749980ca6ca 100644
--- a/drivers/acpi/bus.c
+++ b/drivers/acpi/bus.c
@@ -1007,8 +1007,7 @@ struct kobject *acpi_kobj;
1007 1007
1008static int __init acpi_init(void) 1008static int __init acpi_init(void)
1009{ 1009{
1010 int result = 0; 1010 int result;
1011
1012 1011
1013 if (acpi_disabled) { 1012 if (acpi_disabled) {
1014 printk(KERN_INFO PREFIX "Interpreter disabled.\n"); 1013 printk(KERN_INFO PREFIX "Interpreter disabled.\n");
@@ -1023,29 +1022,18 @@ static int __init acpi_init(void)
1023 1022
1024 init_acpi_device_notify(); 1023 init_acpi_device_notify();
1025 result = acpi_bus_init(); 1024 result = acpi_bus_init();
1026 1025 if (result) {
1027 if (!result) {
1028 pci_mmcfg_late_init();
1029 if (pm_apm_enabled()) {
1030 printk(KERN_INFO PREFIX
1031 "APM is already active, exiting\n");
1032 disable_acpi();
1033 result = -ENODEV;
1034 } else {
1035 pm_set_acpi_flag();
1036 }
1037 } else
1038 disable_acpi(); 1026 disable_acpi();
1039
1040 if (acpi_disabled)
1041 return result; 1027 return result;
1028 }
1042 1029
1030 pci_mmcfg_late_init();
1043 acpi_scan_init(); 1031 acpi_scan_init();
1044 acpi_ec_init(); 1032 acpi_ec_init();
1045 acpi_debugfs_init(); 1033 acpi_debugfs_init();
1046 acpi_sleep_proc_init(); 1034 acpi_sleep_proc_init();
1047 acpi_wakeup_device_init(); 1035 acpi_wakeup_device_init();
1048 return result; 1036 return 0;
1049} 1037}
1050 1038
1051subsys_initcall(acpi_init); 1039subsys_initcall(acpi_init);
diff --git a/include/linux/pm.h b/include/linux/pm.h
index 9279175a4557..1f79c98f1e56 100644
--- a/include/linux/pm.h
+++ b/include/linux/pm.h
@@ -565,15 +565,6 @@ enum dpm_order {
565 DPM_ORDER_DEV_LAST, 565 DPM_ORDER_DEV_LAST,
566}; 566};
567 567
568/*
569 * Global Power Management flags
570 * Used to keep APM and ACPI from both being active
571 */
572extern unsigned int pm_flags;
573
574#define PM_APM 1
575#define PM_ACPI 2
576
577extern int pm_generic_suspend(struct device *dev); 568extern int pm_generic_suspend(struct device *dev);
578extern int pm_generic_resume(struct device *dev); 569extern int pm_generic_resume(struct device *dev);
579extern int pm_generic_freeze(struct device *dev); 570extern int pm_generic_freeze(struct device *dev);
diff --git a/include/linux/suspend.h b/include/linux/suspend.h
index 5e364db8a56a..5a89e3612875 100644
--- a/include/linux/suspend.h
+++ b/include/linux/suspend.h
@@ -272,9 +272,6 @@ extern int unregister_pm_notifier(struct notifier_block *nb);
272 register_pm_notifier(&fn##_nb); \ 272 register_pm_notifier(&fn##_nb); \
273} 273}
274 274
275extern bool pm_apm_enabled(void);
276extern void pm_set_acpi_flag(void);
277
278/* drivers/base/power/wakeup.c */ 275/* drivers/base/power/wakeup.c */
279extern bool events_check_enabled; 276extern bool events_check_enabled;
280 277
@@ -295,9 +292,6 @@ static inline int unregister_pm_notifier(struct notifier_block *nb)
295 292
296#define pm_notifier(fn, pri) do { (void)(fn); } while (0) 293#define pm_notifier(fn, pri) do { (void)(fn); } while (0)
297 294
298static inline bool pm_apm_enabled(void) { return false; }
299static inline void pm_set_acpi_flag(void) {}
300
301static inline bool pm_wakeup_pending(void) { return false; } 295static inline bool pm_wakeup_pending(void) { return false; }
302#endif /* !CONFIG_PM_SLEEP */ 296#endif /* !CONFIG_PM_SLEEP */
303 297
diff --git a/kernel/power/main.c b/kernel/power/main.c
index b5405af48ddb..8eaba5f27b10 100644
--- a/kernel/power/main.c
+++ b/kernel/power/main.c
@@ -19,19 +19,6 @@ DEFINE_MUTEX(pm_mutex);
19 19
20#ifdef CONFIG_PM_SLEEP 20#ifdef CONFIG_PM_SLEEP
21 21
22unsigned int pm_flags;
23EXPORT_SYMBOL(pm_flags);
24
25bool pm_apm_enabled(void)
26{
27 return !!(pm_flags & PM_APM);
28}
29
30void pm_set_acpi_flag(void)
31{
32 pm_flags |= PM_ACPI;
33}
34
35/* Routines for PM-transition notifications */ 22/* Routines for PM-transition notifications */
36 23
37static BLOCKING_NOTIFIER_HEAD(pm_chain_head); 24static BLOCKING_NOTIFIER_HEAD(pm_chain_head);