Skip to content

Commit 6831c6e

Browse files
committed
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 <[email protected]> Acked-by: Len Brown <[email protected]>
1 parent e866500 commit 6831c6e

File tree

5 files changed

+7
-48
lines changed

5 files changed

+7
-48
lines changed

arch/x86/kernel/apm_32.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@
227227
#include <linux/suspend.h>
228228
#include <linux/kthread.h>
229229
#include <linux/jiffies.h>
230+
#include <linux/acpi.h>
230231

231232
#include <asm/system.h>
232233
#include <asm/uaccess.h>
@@ -2331,12 +2332,11 @@ static int __init apm_init(void)
23312332
apm_info.disabled = 1;
23322333
return -ENODEV;
23332334
}
2334-
if (pm_flags & PM_ACPI) {
2335+
if (!acpi_disabled) {
23352336
printk(KERN_NOTICE "apm: overridden by ACPI.\n");
23362337
apm_info.disabled = 1;
23372338
return -ENODEV;
23382339
}
2339-
pm_flags |= PM_APM;
23402340

23412341
/*
23422342
* Set up the long jump entry point to the APM BIOS, which is called
@@ -2428,7 +2428,6 @@ static void __exit apm_exit(void)
24282428
kthread_stop(kapmd_task);
24292429
kapmd_task = NULL;
24302430
}
2431-
pm_flags &= ~PM_APM;
24322431
}
24332432

24342433
module_init(apm_init);

drivers/acpi/bus.c

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1007,8 +1007,7 @@ struct kobject *acpi_kobj;
10071007

10081008
static int __init acpi_init(void)
10091009
{
1010-
int result = 0;
1011-
1010+
int result;
10121011

10131012
if (acpi_disabled) {
10141013
printk(KERN_INFO PREFIX "Interpreter disabled.\n");
@@ -1023,29 +1022,18 @@ static int __init acpi_init(void)
10231022

10241023
init_acpi_device_notify();
10251024
result = acpi_bus_init();
1026-
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
1025+
if (result) {
10381026
disable_acpi();
1039-
1040-
if (acpi_disabled)
10411027
return result;
1028+
}
10421029

1030+
pci_mmcfg_late_init();
10431031
acpi_scan_init();
10441032
acpi_ec_init();
10451033
acpi_debugfs_init();
10461034
acpi_sleep_proc_init();
10471035
acpi_wakeup_device_init();
1048-
return result;
1036+
return 0;
10491037
}
10501038

10511039
subsys_initcall(acpi_init);

include/linux/pm.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -565,15 +565,6 @@ enum dpm_order {
565565
DPM_ORDER_DEV_LAST,
566566
};
567567

568-
/*
569-
* Global Power Management flags
570-
* Used to keep APM and ACPI from both being active
571-
*/
572-
extern unsigned int pm_flags;
573-
574-
#define PM_APM 1
575-
#define PM_ACPI 2
576-
577568
extern int pm_generic_suspend(struct device *dev);
578569
extern int pm_generic_resume(struct device *dev);
579570
extern int pm_generic_freeze(struct device *dev);

include/linux/suspend.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -272,9 +272,6 @@ extern int unregister_pm_notifier(struct notifier_block *nb);
272272
register_pm_notifier(&fn##_nb); \
273273
}
274274

275-
extern bool pm_apm_enabled(void);
276-
extern void pm_set_acpi_flag(void);
277-
278275
/* drivers/base/power/wakeup.c */
279276
extern bool events_check_enabled;
280277

@@ -295,9 +292,6 @@ static inline int unregister_pm_notifier(struct notifier_block *nb)
295292

296293
#define pm_notifier(fn, pri) do { (void)(fn); } while (0)
297294

298-
static inline bool pm_apm_enabled(void) { return false; }
299-
static inline void pm_set_acpi_flag(void) {}
300-
301295
static inline bool pm_wakeup_pending(void) { return false; }
302296
#endif /* !CONFIG_PM_SLEEP */
303297

kernel/power/main.c

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,6 @@ DEFINE_MUTEX(pm_mutex);
1919

2020
#ifdef CONFIG_PM_SLEEP
2121

22-
unsigned int pm_flags;
23-
EXPORT_SYMBOL(pm_flags);
24-
25-
bool pm_apm_enabled(void)
26-
{
27-
return !!(pm_flags & PM_APM);
28-
}
29-
30-
void pm_set_acpi_flag(void)
31-
{
32-
pm_flags |= PM_ACPI;
33-
}
34-
3522
/* Routines for PM-transition notifications */
3623

3724
static BLOCKING_NOTIFIER_HEAD(pm_chain_head);

0 commit comments

Comments
 (0)