From e60cc7a6f02598fc23c68a656fe9c263d6531ca0 Mon Sep 17 00:00:00 2001 From: Bjorn Helgaas Date: Fri, 13 Mar 2009 12:08:26 -0600 Subject: ACPI: move private declarations to internal.h A number of things that shouldn't be exposed outside the ACPI core were declared in include/acpi/acpi_drivers.h, where anybody can see them. This patch moves those declarations to a new "internal.h" inside drivers/acpi. Signed-off-by: Bjorn Helgaas Signed-off-by: Len Brown --- drivers/acpi/bus.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'drivers/acpi/bus.c') diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c index 765fd1c56cd6..2e90410a3035 100644 --- a/drivers/acpi/bus.c +++ b/drivers/acpi/bus.c @@ -39,6 +39,8 @@ #include #include +#include "internal.h" + #define _COMPONENT ACPI_BUS_COMPONENT ACPI_MODULE_NAME("bus"); -- cgit v1.2.3 From 81d0273df20edff275e2eefe6b50436af3bdf9e8 Mon Sep 17 00:00:00 2001 From: Bjorn Helgaas Date: Tue, 24 Mar 2009 16:49:38 -0600 Subject: ACPI: skip DMI power state check when ACPI disabled This patch makes acpi_init() exit early when ACPI is disabled. This skips a DMI check that affects ACPI power management. The DMI check prints a notice that is misleading when ACPI is disabled. Signed-off-by: Bjorn Helgaas Signed-off-by: Len Brown --- drivers/acpi/bus.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'drivers/acpi/bus.c') diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c index 2e90410a3035..bdeed39c3d38 100644 --- a/drivers/acpi/bus.c +++ b/drivers/acpi/bus.c @@ -869,6 +869,10 @@ static int __init acpi_init(void) } } else disable_acpi(); + + if (acpi_disabled) + return result; + /* * If the laptop falls into the DMI check table, the power state check * will be disabled in the course of device power transistion. -- cgit v1.2.3 From e747f274951507b5a0850155c3d709e26d20de5b Mon Sep 17 00:00:00 2001 From: Bjorn Helgaas Date: Tue, 24 Mar 2009 16:49:43 -0600 Subject: ACPI: call acpi_scan_init() explicitly rather than as initcall This patch makes acpi_init() call acpi_scan_init() directly. Previously, both acpi_init() and acpi_scan_init() were subsys_initcalls, and acpi_init() was called first based on the link order from the makefile (bus.o before scan.o). acpi_scan_init() registers the ACPI bus type, creates the root device, and enumerates fixed-feature and namespace devices. All of this must be done after acpi_init(), and it's better to call acpi_scan_init() explicitly rather than rely on the link ordering. Signed-off-by: Bjorn Helgaas Signed-off-by: Len Brown --- drivers/acpi/bus.c | 2 ++ drivers/acpi/internal.h | 2 ++ drivers/acpi/scan.c | 9 +-------- 3 files changed, 5 insertions(+), 8 deletions(-) (limited to 'drivers/acpi/bus.c') diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c index bdeed39c3d38..cdd11fda5036 100644 --- a/drivers/acpi/bus.c +++ b/drivers/acpi/bus.c @@ -878,6 +878,8 @@ static int __init acpi_init(void) * will be disabled in the course of device power transistion. */ dmi_check_system(power_nocheck_dmi_table); + + acpi_scan_init(); return result; } diff --git a/drivers/acpi/internal.h b/drivers/acpi/internal.h index 4aee4a236fc9..28042c0f2fff 100644 --- a/drivers/acpi/internal.h +++ b/drivers/acpi/internal.h @@ -1,5 +1,7 @@ /* For use by Linux/ACPI infrastructure, not drivers */ +int acpi_scan_init(void); + /* -------------------------------------------------------------------------- Power Resource -------------------------------------------------------------------------- */ diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index 2f04cd1147e9..c548231965ef 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c @@ -1526,16 +1526,11 @@ static int acpi_bus_scan_fixed(struct acpi_device *root) return result; } - -static int __init acpi_scan_init(void) +int __init acpi_scan_init(void) { int result; struct acpi_bus_ops ops; - - if (acpi_disabled) - return 0; - memset(&ops, 0, sizeof(ops)); ops.acpi_op_add = 1; ops.acpi_op_start = 1; @@ -1568,5 +1563,3 @@ static int __init acpi_scan_init(void) Done: return result; } - -subsys_initcall(acpi_scan_init); -- cgit v1.2.3 From a5f820feb54a59fcdaf4a67a6381ea1ddb36cc6e Mon Sep 17 00:00:00 2001 From: Bjorn Helgaas Date: Tue, 24 Mar 2009 16:49:48 -0600 Subject: ACPI: call acpi_ec_init() explicitly rather than as initcall This patch makes acpi_init() call acpi_ec_init() directly. Previously, both were subsys_initcalls. acpi_ec_init() must happen after acpi_init(), and it's better to call it explicitly rather than rely on link ordering. Signed-off-by: Bjorn Helgaas CC: Alexey Starikovskiy Signed-off-by: Len Brown --- drivers/acpi/bus.c | 1 + drivers/acpi/ec.c | 7 +------ drivers/acpi/internal.h | 1 + 3 files changed, 3 insertions(+), 6 deletions(-) (limited to 'drivers/acpi/bus.c') diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c index cdd11fda5036..9ca683794370 100644 --- a/drivers/acpi/bus.c +++ b/drivers/acpi/bus.c @@ -880,6 +880,7 @@ static int __init acpi_init(void) dmi_check_system(power_nocheck_dmi_table); acpi_scan_init(); + acpi_ec_init(); return result; } diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c index 2fe15060dcdc..bf88f1803801 100644 --- a/drivers/acpi/ec.c +++ b/drivers/acpi/ec.c @@ -1069,13 +1069,10 @@ static struct acpi_driver acpi_ec_driver = { }, }; -static int __init acpi_ec_init(void) +int __init acpi_ec_init(void) { int result = 0; - if (acpi_disabled) - return 0; - acpi_ec_dir = proc_mkdir(ACPI_EC_CLASS, acpi_root_dir); if (!acpi_ec_dir) return -ENODEV; @@ -1090,8 +1087,6 @@ static int __init acpi_ec_init(void) return result; } -subsys_initcall(acpi_ec_init); - /* EC driver currently not unloadable */ #if 0 static void __exit acpi_ec_exit(void) diff --git a/drivers/acpi/internal.h b/drivers/acpi/internal.h index 28042c0f2fff..fad8e38ed271 100644 --- a/drivers/acpi/internal.h +++ b/drivers/acpi/internal.h @@ -17,6 +17,7 @@ extern int acpi_power_nocheck; /* -------------------------------------------------------------------------- Embedded Controller -------------------------------------------------------------------------- */ +int acpi_ec_init(void); int acpi_ec_ecdt_probe(void); int acpi_boot_ec_enable(void); -- cgit v1.2.3 From 44515374cba9e46d5622256b43eb06b9c349cee1 Mon Sep 17 00:00:00 2001 From: Bjorn Helgaas Date: Tue, 24 Mar 2009 16:49:53 -0600 Subject: ACPI: call acpi_power_init() explicitly rather than as initcall This patch makes acpi_init() call acpi_power_init() directly. Previously, both were subsys_initcalls. acpi_power_init() must happen after acpi_init(), and it's better to call it explicitly rather than rely on link ordering. Signed-off-by: Bjorn Helgaas CC: Zhao Yakui Signed-off-by: Len Brown --- drivers/acpi/bus.c | 1 + drivers/acpi/internal.h | 2 +- drivers/acpi/power.c | 8 +------- 3 files changed, 3 insertions(+), 8 deletions(-) (limited to 'drivers/acpi/bus.c') diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c index 9ca683794370..946610f00aa1 100644 --- a/drivers/acpi/bus.c +++ b/drivers/acpi/bus.c @@ -881,6 +881,7 @@ static int __init acpi_init(void) acpi_scan_init(); acpi_ec_init(); + acpi_power_init(); return result; } diff --git a/drivers/acpi/internal.h b/drivers/acpi/internal.h index fad8e38ed271..a8178add7fd1 100644 --- a/drivers/acpi/internal.h +++ b/drivers/acpi/internal.h @@ -5,7 +5,7 @@ int acpi_scan_init(void); /* -------------------------------------------------------------------------- Power Resource -------------------------------------------------------------------------- */ - +int acpi_power_init(void); int acpi_device_sleep_wake(struct acpi_device *dev, int enable, int sleep_state, int dev_state); int acpi_enable_wakeup_device_power(struct acpi_device *dev, int sleep_state); diff --git a/drivers/acpi/power.c b/drivers/acpi/power.c index c926e7d4a0d6..11968ba28feb 100644 --- a/drivers/acpi/power.c +++ b/drivers/acpi/power.c @@ -773,14 +773,10 @@ static int acpi_power_resume(struct acpi_device *device) return 0; } -static int __init acpi_power_init(void) +int __init acpi_power_init(void) { int result = 0; - - if (acpi_disabled) - return 0; - INIT_LIST_HEAD(&acpi_power_resource_list); acpi_power_dir = proc_mkdir(ACPI_POWER_CLASS, acpi_root_dir); @@ -795,5 +791,3 @@ static int __init acpi_power_init(void) return 0; } - -subsys_initcall(acpi_power_init); -- cgit v1.2.3 From 141a0af3cab7de690816b17aad1682050219f774 Mon Sep 17 00:00:00 2001 From: Bjorn Helgaas Date: Tue, 24 Mar 2009 16:49:58 -0600 Subject: ACPI: call acpi_system_init() explicitly rather than as initcall This patch makes acpi_init() call acpi_system_init() directly. Previously, both were subsys_initcalls. acpi_system_init() must happen after acpi_init(), and it's better to call it explicitly rather than rely on link ordering. Signed-off-by: Bjorn Helgaas Signed-off-by: Len Brown --- drivers/acpi/bus.c | 1 + drivers/acpi/internal.h | 1 + drivers/acpi/system.c | 9 ++------- 3 files changed, 4 insertions(+), 7 deletions(-) (limited to 'drivers/acpi/bus.c') diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c index 946610f00aa1..c13307279f7e 100644 --- a/drivers/acpi/bus.c +++ b/drivers/acpi/bus.c @@ -882,6 +882,7 @@ static int __init acpi_init(void) acpi_scan_init(); acpi_ec_init(); acpi_power_init(); + acpi_system_init(); return result; } diff --git a/drivers/acpi/internal.h b/drivers/acpi/internal.h index a8178add7fd1..4a35f6e819d3 100644 --- a/drivers/acpi/internal.h +++ b/drivers/acpi/internal.h @@ -1,6 +1,7 @@ /* For use by Linux/ACPI infrastructure, not drivers */ int acpi_scan_init(void); +int acpi_system_init(void); /* -------------------------------------------------------------------------- Power Resource diff --git a/drivers/acpi/system.c b/drivers/acpi/system.c index 391d0358a592..3b88981dd215 100644 --- a/drivers/acpi/system.c +++ b/drivers/acpi/system.c @@ -571,12 +571,9 @@ static int acpi_system_procfs_init(void) } #endif -static int __init acpi_system_init(void) +int __init acpi_system_init(void) { - int result = 0; - - if (acpi_disabled) - return 0; + int result; result = acpi_system_procfs_init(); if (result) @@ -586,5 +583,3 @@ static int __init acpi_system_init(void) return result; } - -subsys_initcall(acpi_system_init); -- cgit v1.2.3 From 84f810c33f695e020776ce66c903e0b41872f1b2 Mon Sep 17 00:00:00 2001 From: Bjorn Helgaas Date: Tue, 24 Mar 2009 16:50:03 -0600 Subject: ACPI: call acpi_debug_init() explicitly rather than as initcall This patch makes acpi_init() call acpi_debug_init() directly. Previously, both were subsys_initcalls. acpi_debug_init() must happen after acpi_init(), and it's better to call it explicitly rather than rely on link ordering. Signed-off-by: Bjorn Helgaas Signed-off-by: Len Brown --- drivers/acpi/bus.c | 1 + drivers/acpi/debug.c | 14 ++++++-------- drivers/acpi/internal.h | 6 ++++++ 3 files changed, 13 insertions(+), 8 deletions(-) (limited to 'drivers/acpi/bus.c') diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c index c13307279f7e..f32cfd64c999 100644 --- a/drivers/acpi/bus.c +++ b/drivers/acpi/bus.c @@ -883,6 +883,7 @@ static int __init acpi_init(void) acpi_ec_init(); acpi_power_init(); acpi_system_init(); + acpi_debug_init(); return result; } diff --git a/drivers/acpi/debug.c b/drivers/acpi/debug.c index 20223cbd0d1c..9cb189f3c77c 100644 --- a/drivers/acpi/debug.c +++ b/drivers/acpi/debug.c @@ -297,17 +297,15 @@ acpi_system_write_debug(struct file *file, return count; } +#endif -static int __init acpi_debug_init(void) +int __init acpi_debug_init(void) { +#ifdef CONFIG_ACPI_PROCFS struct proc_dir_entry *entry; int error = 0; char *name; - - if (acpi_disabled) - return 0; - /* 'debug_layer' [R/W] */ name = ACPI_SYSTEM_FILE_DEBUG_LAYER; entry = @@ -338,7 +336,7 @@ static int __init acpi_debug_init(void) remove_proc_entry(ACPI_SYSTEM_FILE_DEBUG_LAYER, acpi_root_dir); error = -ENODEV; goto Done; -} - -subsys_initcall(acpi_debug_init); +#else + return 0; #endif +} diff --git a/drivers/acpi/internal.h b/drivers/acpi/internal.h index 4a35f6e819d3..44b84021d84d 100644 --- a/drivers/acpi/internal.h +++ b/drivers/acpi/internal.h @@ -3,6 +3,12 @@ int acpi_scan_init(void); int acpi_system_init(void); +#ifdef CONFIG_ACPI_DEBUG +int acpi_debug_init(void); +#else +static inline int acpi_debug_init(void) { return 0; } +#endif + /* -------------------------------------------------------------------------- Power Resource -------------------------------------------------------------------------- */ -- cgit v1.2.3 From 0e46517d9660ee6ae0a0c5d8a4e50451bc84d61d Mon Sep 17 00:00:00 2001 From: Bjorn Helgaas Date: Tue, 24 Mar 2009 16:50:09 -0600 Subject: ACPI: call init_acpi_device_notify() explicitly rather than as initcall This patch makes acpi_init() call init_acpi_device_notify() directly. Previously, init_acpi_device_notify() was an arch_initcall (sequence 3), so it was called before acpi_init() (a subsys_initcall at sequence 4). init_acpi_device_notify() sets the platform_notify and platform_notify_remove function pointers. These pointers are not used until acpi_init() enumerates ACPI devices in this path: acpi_init() acpi_scan_init() acpi_bus_scan() acpi_add_single_object() acpi_device_register() device_add() So it is sufficient to have acpi_init() call init_acpi_device_notify() directly before it enumerates devices. Signed-off-by: Bjorn Helgaas Signed-off-by: Len Brown --- drivers/acpi/bus.c | 1 + drivers/acpi/glue.c | 6 +----- drivers/acpi/internal.h | 1 + 3 files changed, 3 insertions(+), 5 deletions(-) (limited to 'drivers/acpi/bus.c') diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c index f32cfd64c999..db9eca8d3cf2 100644 --- a/drivers/acpi/bus.c +++ b/drivers/acpi/bus.c @@ -855,6 +855,7 @@ static int __init acpi_init(void) acpi_kobj = NULL; } + init_acpi_device_notify(); result = acpi_bus_init(); if (!result) { diff --git a/drivers/acpi/glue.c b/drivers/acpi/glue.c index 5479b9f42513..8bd2c2a6884d 100644 --- a/drivers/acpi/glue.c +++ b/drivers/acpi/glue.c @@ -286,10 +286,8 @@ static int acpi_platform_notify_remove(struct device *dev) return 0; } -static int __init init_acpi_device_notify(void) +int __init init_acpi_device_notify(void) { - if (acpi_disabled) - return 0; if (platform_notify || platform_notify_remove) { printk(KERN_ERR PREFIX "Can't use platform_notify\n"); return 0; @@ -298,5 +296,3 @@ static int __init init_acpi_device_notify(void) platform_notify_remove = acpi_platform_notify_remove; return 0; } - -arch_initcall(init_acpi_device_notify); diff --git a/drivers/acpi/internal.h b/drivers/acpi/internal.h index 44b84021d84d..8a45dd8e03b5 100644 --- a/drivers/acpi/internal.h +++ b/drivers/acpi/internal.h @@ -1,5 +1,6 @@ /* For use by Linux/ACPI infrastructure, not drivers */ +int init_acpi_device_notify(void); int acpi_scan_init(void); int acpi_system_init(void); -- cgit v1.2.3 From 9cee43e07940bee13462e63bd75ce4430b155886 Mon Sep 17 00:00:00 2001 From: Bjorn Helgaas Date: Tue, 24 Mar 2009 16:50:14 -0600 Subject: ACPI: call acpi_sleep_proc_init() explicitly rather than as initcall This patch makes acpi_init() call acpi_sleep_proc_init() directly. Previously, acpi_sleep_proc_init() was a late_initcall (sequence 7), apparently to make sure that the /proc hierarchy already exists: 2003/02/13 12:38:03-06:00 mochel acpi sleep: demote sleep proc file creation. - Make acpi_sleep_proc_init() a late_initcall(), and not called from acpi_sleep_init(). This guarantees that the acpi proc hierarchy is at least there when we create the dang file. This should no longer be an issue because acpi_bus_init() (called early in acpi_init()) creates acpi_root_dir (/proc/acpi). Signed-off-by: Bjorn Helgaas Signed-off-by: Len Brown --- drivers/acpi/bus.c | 1 + drivers/acpi/internal.h | 6 ++++++ drivers/acpi/proc.c | 7 +------ 3 files changed, 8 insertions(+), 6 deletions(-) (limited to 'drivers/acpi/bus.c') diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c index db9eca8d3cf2..a812e841cb64 100644 --- a/drivers/acpi/bus.c +++ b/drivers/acpi/bus.c @@ -885,6 +885,7 @@ static int __init acpi_init(void) acpi_power_init(); acpi_system_init(); acpi_debug_init(); + acpi_sleep_proc_init(); return result; } diff --git a/drivers/acpi/internal.h b/drivers/acpi/internal.h index 8a45dd8e03b5..8870e5fd8494 100644 --- a/drivers/acpi/internal.h +++ b/drivers/acpi/internal.h @@ -33,3 +33,9 @@ int acpi_boot_ec_enable(void); Suspend/Resume -------------------------------------------------------------------------- */ extern int acpi_sleep_init(void); + +#ifdef CONFIG_ACPI_SLEEP +int acpi_sleep_proc_init(void); +#else +static inline int acpi_sleep_proc_init(void) { return 0; } +#endif diff --git a/drivers/acpi/proc.c b/drivers/acpi/proc.c index 428c911dba08..05dfdc96802e 100644 --- a/drivers/acpi/proc.c +++ b/drivers/acpi/proc.c @@ -496,11 +496,8 @@ static u32 rtc_handler(void *context) } #endif /* HAVE_ACPI_LEGACY_ALARM */ -static int __init acpi_sleep_proc_init(void) +int __init acpi_sleep_proc_init(void) { - if (acpi_disabled) - return 0; - #ifdef CONFIG_ACPI_PROCFS /* 'sleep' [R/W] */ proc_create("sleep", S_IFREG | S_IRUGO | S_IWUSR, @@ -527,5 +524,3 @@ static int __init acpi_sleep_proc_init(void) return 0; } - -late_initcall(acpi_sleep_proc_init); -- cgit v1.2.3 From 201b8c655f7a48563f6a0b66f9e388460a1ea611 Mon Sep 17 00:00:00 2001 From: Bjorn Helgaas Date: Tue, 24 Mar 2009 16:50:19 -0600 Subject: ACPI: call acpi_wakeup_device_init() explicitly rather than as initcall This patch makes acpi_init() call acpi_wakeup_device_init() directly. Previously, acpi_wakeup_device_init() was a late_initcall (sequence 7). acpi_wakeup_device_init() depends on acpi_wakeup_device_list, which is populated when ACPI devices are enumerated by acpi_init() -> acpi_scan_init(). Using late_initcall is certainly enough to make sure acpi_wakeup_device_list is populated, but it is more than necessary. We can just as easily call acpi_wakeup_device_init() directly from acpi_init(), which avoids the initcall magic. Signed-off-by: Bjorn Helgaas CC: Li Shaohua Signed-off-by: Len Brown --- drivers/acpi/bus.c | 1 + drivers/acpi/internal.h | 2 ++ drivers/acpi/wakeup.c | 7 +------ 3 files changed, 4 insertions(+), 6 deletions(-) (limited to 'drivers/acpi/bus.c') diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c index a812e841cb64..7fe0945f7bcf 100644 --- a/drivers/acpi/bus.c +++ b/drivers/acpi/bus.c @@ -886,6 +886,7 @@ static int __init acpi_init(void) acpi_system_init(); acpi_debug_init(); acpi_sleep_proc_init(); + acpi_wakeup_device_init(); return result; } diff --git a/drivers/acpi/internal.h b/drivers/acpi/internal.h index 8870e5fd8494..11a69b53004e 100644 --- a/drivers/acpi/internal.h +++ b/drivers/acpi/internal.h @@ -22,6 +22,8 @@ int acpi_power_get_inferred_state(struct acpi_device *device); int acpi_power_transition(struct acpi_device *device, int state); extern int acpi_power_nocheck; +int acpi_wakeup_device_init(void); + /* -------------------------------------------------------------------------- Embedded Controller -------------------------------------------------------------------------- */ diff --git a/drivers/acpi/wakeup.c b/drivers/acpi/wakeup.c index 3f29fd53e9a6..5aee8c26cc9f 100644 --- a/drivers/acpi/wakeup.c +++ b/drivers/acpi/wakeup.c @@ -138,13 +138,10 @@ void acpi_disable_wakeup_device(u8 sleep_state) spin_unlock(&acpi_device_lock); } -static int __init acpi_wakeup_device_init(void) +int __init acpi_wakeup_device_init(void) { struct list_head *node, *next; - if (acpi_disabled) - return 0; - spin_lock(&acpi_device_lock); list_for_each_safe(node, next, &acpi_wakeup_device_list) { struct acpi_device *dev = container_of(node, @@ -165,5 +162,3 @@ static int __init acpi_wakeup_device_init(void) spin_unlock(&acpi_device_lock); return 0; } - -late_initcall(acpi_wakeup_device_init); -- cgit v1.2.3