ACPI: call init_acpi_device_notify() explicitly rather than as initcall
[safe/jmp/linux-2.6] / drivers / acpi / bus.c
index e9b116d..db9eca8 100644 (file)
@@ -39,6 +39,8 @@
 #include <acpi/acpi_bus.h>
 #include <acpi/acpi_drivers.h>
 
+#include "internal.h"
+
 #define _COMPONENT             ACPI_BUS_COMPONENT
 ACPI_MODULE_NAME("bus");
 
@@ -94,7 +96,7 @@ EXPORT_SYMBOL(acpi_bus_get_device);
 int acpi_bus_get_status(struct acpi_device *device)
 {
        acpi_status status = AE_OK;
-       unsigned long sta = 0;
+       unsigned long long sta = 0;
 
 
        if (!device)
@@ -172,7 +174,7 @@ int acpi_bus_get_power(acpi_handle handle, int *state)
        int result = 0;
        acpi_status status = 0;
        struct acpi_device *device = NULL;
-       unsigned long psc = 0;
+       unsigned long long psc = 0;
 
 
        result = acpi_bus_get_device(handle, &device);
@@ -525,6 +527,19 @@ static int acpi_bus_check_scope(struct acpi_device *device)
        return 0;
 }
 
+static BLOCKING_NOTIFIER_HEAD(acpi_bus_notify_list);
+int register_acpi_bus_notifier(struct notifier_block *nb)
+{
+       return blocking_notifier_chain_register(&acpi_bus_notify_list, nb);
+}
+EXPORT_SYMBOL_GPL(register_acpi_bus_notifier);
+
+void unregister_acpi_bus_notifier(struct notifier_block *nb)
+{
+       blocking_notifier_chain_unregister(&acpi_bus_notify_list, nb);
+}
+EXPORT_SYMBOL_GPL(unregister_acpi_bus_notifier);
+
 /**
  * acpi_bus_notify
  * ---------------
@@ -535,6 +550,8 @@ static void acpi_bus_notify(acpi_handle handle, u32 type, void *data)
        int result = 0;
        struct acpi_device *device = NULL;
 
+       blocking_notifier_call_chain(&acpi_bus_notify_list,
+               type, (void *)handle);
 
        if (acpi_bus_get_device(handle, &device))
                return;
@@ -759,7 +776,7 @@ static int __init acpi_bus_init(void)
                       "Unable to initialize ACPI OS objects\n");
                goto error1;
        }
-#ifdef CONFIG_ACPI_EC
+
        /*
         * ACPI 2.0 requires the EC driver to be loaded and work before
         * the EC device is found in the namespace (i.e. before acpi_initialize_objects()
@@ -770,7 +787,6 @@ static int __init acpi_bus_init(void)
         */
        status = acpi_ec_ecdt_probe();
        /* Ignore result. Not having an ECDT is not fatal. */
-#endif
 
        status = acpi_initialize_objects(ACPI_FULL_INITIALIZATION);
        if (ACPI_FAILURE(status)) {
@@ -778,6 +794,12 @@ static int __init acpi_bus_init(void)
                goto error1;
        }
 
+       /*
+        * Maybe EC region is required at bus_scan/acpi_get_devices. So it
+        * is necessary to enable it as early as possible.
+        */
+       acpi_boot_ec_enable();
+
        printk(KERN_INFO PREFIX "Interpreter enabled\n");
 
        /* Initialize sleep structures */
@@ -833,6 +855,7 @@ static int __init acpi_init(void)
                acpi_kobj = NULL;
        }
 
+       init_acpi_device_notify();
        result = acpi_bus_init();
 
        if (!result) {
@@ -847,11 +870,21 @@ 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.
         */
        dmi_check_system(power_nocheck_dmi_table);
+
+       acpi_scan_init();
+       acpi_ec_init();
+       acpi_power_init();
+       acpi_system_init();
+       acpi_debug_init();
        return result;
 }