Merge branch 'v2.6.34-rc2' into drm-linus
[safe/jmp/linux-2.6] / drivers / acpi / button.c
index ebb593e..f53fbe3 100644 (file)
@@ -33,6 +33,8 @@
 #include <acpi/acpi_bus.h>
 #include <acpi/acpi_drivers.h>
 
+#define PREFIX "ACPI: "
+
 #define ACPI_BUTTON_CLASS              "button"
 #define ACPI_BUTTON_FILE_INFO          "info"
 #define ACPI_BUTTON_FILE_STATE         "state"
@@ -249,6 +251,9 @@ int acpi_lid_open(void)
        acpi_status status;
        unsigned long long state;
 
+       if (!lid_device)
+               return -ENODEV;
+
        status = acpi_evaluate_integer(lid_device->handle, "_LID", NULL,
                                       &state);
        if (ACPI_FAILURE(status))
@@ -277,6 +282,13 @@ static int acpi_lid_send_state(struct acpi_device *device)
        if (ret == NOTIFY_DONE)
                ret = blocking_notifier_call_chain(&acpi_lid_notifier, state,
                                                   device);
+       if (ret == NOTIFY_DONE || ret == NOTIFY_OK) {
+               /*
+                * It is also regarded as success if the notifier_chain
+                * returns NOTIFY_OK or NOTIFY_DONE.
+                */
+               ret = 0;
+       }
        return ret;
 }
 
@@ -410,11 +422,10 @@ static int acpi_button_add(struct acpi_device *device)
 
        if (device->wakeup.flags.valid) {
                /* Button's GPE is run-wake GPE */
-               acpi_set_gpe_type(device->wakeup.gpe_device,
-                                 device->wakeup.gpe_number,
-                                 ACPI_GPE_TYPE_WAKE_RUN);
                acpi_enable_gpe(device->wakeup.gpe_device,
-                               device->wakeup.gpe_number);
+                               device->wakeup.gpe_number,
+                               ACPI_GPE_TYPE_WAKE_RUN);
+               device->wakeup.run_wake_count++;
                device->wakeup.state.enabled = 1;
        }
 
@@ -434,6 +445,14 @@ static int acpi_button_remove(struct acpi_device *device, int type)
 {
        struct acpi_button *button = acpi_driver_data(device);
 
+       if (device->wakeup.flags.valid) {
+               acpi_disable_gpe(device->wakeup.gpe_device,
+                               device->wakeup.gpe_number,
+                               ACPI_GPE_TYPE_WAKE_RUN);
+               device->wakeup.run_wake_count--;
+               device->wakeup.state.enabled = 0;
+       }
+
        acpi_button_remove_fs(device);
        input_unregister_device(button->input);
        kfree(button);