Merge branch 'ec' into release
[sfrench/cifs-2.6.git] / drivers / acpi / ec.c
index dc5561809529c4a2c09eb15828582878c2589826..08b8cf79946b6735291e709e7ef59b68b4dccd70 100644 (file)
@@ -47,7 +47,6 @@
 #define ACPI_EC_DEVICE_NAME            "Embedded Controller"
 #define ACPI_EC_FILE_INFO              "info"
 
-#undef PREFIX
 #define PREFIX                         "ACPI: EC: "
 
 /* EC status register */
@@ -744,6 +743,42 @@ ec_parse_device(acpi_handle handle, u32 Level, void *context, void **retval)
        return AE_CTRL_TERMINATE;
 }
 
+static int ec_install_handlers(struct acpi_ec *ec)
+{
+       acpi_status status;
+       if (test_bit(EC_FLAGS_HANDLERS_INSTALLED, &ec->flags))
+               return 0;
+       status = acpi_install_gpe_handler(NULL, ec->gpe,
+                                 ACPI_GPE_EDGE_TRIGGERED,
+                                 &acpi_ec_gpe_handler, ec);
+       if (ACPI_FAILURE(status))
+               return -ENODEV;
+       acpi_set_gpe_type(NULL, ec->gpe, ACPI_GPE_TYPE_RUNTIME);
+       acpi_enable_gpe(NULL, ec->gpe);
+       status = acpi_install_address_space_handler(ec->handle,
+                                                   ACPI_ADR_SPACE_EC,
+                                                   &acpi_ec_space_handler,
+                                                   NULL, ec);
+       if (ACPI_FAILURE(status)) {
+               if (status == AE_NOT_FOUND) {
+                       /*
+                        * Maybe OS fails in evaluating the _REG object.
+                        * The AE_NOT_FOUND error will be ignored and OS
+                        * continue to initialize EC.
+                        */
+                       printk(KERN_ERR "Fail in evaluating the _REG object"
+                               " of EC device. Broken bios is suspected.\n");
+               } else {
+                       acpi_remove_gpe_handler(NULL, ec->gpe,
+                               &acpi_ec_gpe_handler);
+                       return -ENODEV;
+               }
+       }
+
+       set_bit(EC_FLAGS_HANDLERS_INSTALLED, &ec->flags);
+       return 0;
+}
+
 static void ec_remove_handlers(struct acpi_ec *ec)
 {
        if (ACPI_FAILURE(acpi_remove_address_space_handler(ec->handle,
@@ -758,9 +793,8 @@ static void ec_remove_handlers(struct acpi_ec *ec)
 static int acpi_ec_add(struct acpi_device *device)
 {
        struct acpi_ec *ec = NULL;
+       int ret;
 
-       if (!device)
-               return -EINVAL;
        strcpy(acpi_device_name(device), ACPI_EC_DEVICE_NAME);
        strcpy(acpi_device_class(device), ACPI_EC_CLASS);
 
@@ -793,7 +827,12 @@ static int acpi_ec_add(struct acpi_device *device)
        acpi_ec_add_fs(device);
        pr_info(PREFIX "GPE = 0x%lx, I/O: command/status = 0x%lx, data = 0x%lx\n",
                          ec->gpe, ec->command_addr, ec->data_addr);
-       return 0;
+
+       ret = ec_install_handlers(ec);
+
+       /* EC is fully operational, allow queries */
+       clear_bit(EC_FLAGS_QUERY_PENDING, &ec->flags);
+       return ret;
 }
 
 static int acpi_ec_remove(struct acpi_device *device, int type)
@@ -805,6 +844,7 @@ static int acpi_ec_remove(struct acpi_device *device, int type)
                return -EINVAL;
 
        ec = acpi_driver_data(device);
+       ec_remove_handlers(ec);
        mutex_lock(&ec->lock);
        list_for_each_entry_safe(handler, tmp, &ec->list, node) {
                list_del(&handler->node);
@@ -842,75 +882,6 @@ ec_parse_io_ports(struct acpi_resource *resource, void *context)
        return AE_OK;
 }
 
-static int ec_install_handlers(struct acpi_ec *ec)
-{
-       acpi_status status;
-       if (test_bit(EC_FLAGS_HANDLERS_INSTALLED, &ec->flags))
-               return 0;
-       status = acpi_install_gpe_handler(NULL, ec->gpe,
-                                 ACPI_GPE_EDGE_TRIGGERED,
-                                 &acpi_ec_gpe_handler, ec);
-       if (ACPI_FAILURE(status))
-               return -ENODEV;
-       acpi_set_gpe_type(NULL, ec->gpe, ACPI_GPE_TYPE_RUNTIME);
-       acpi_enable_gpe(NULL, ec->gpe);
-       status = acpi_install_address_space_handler(ec->handle,
-                                                   ACPI_ADR_SPACE_EC,
-                                                   &acpi_ec_space_handler,
-                                                   NULL, ec);
-       if (ACPI_FAILURE(status)) {
-               if (status == AE_NOT_FOUND) {
-                       /*
-                        * Maybe OS fails in evaluating the _REG object.
-                        * The AE_NOT_FOUND error will be ignored and OS
-                        * continue to initialize EC.
-                        */
-                       printk(KERN_ERR "Fail in evaluating the _REG object"
-                               " of EC device. Broken bios is suspected.\n");
-               } else {
-                       acpi_remove_gpe_handler(NULL, ec->gpe,
-                               &acpi_ec_gpe_handler);
-                       return -ENODEV;
-               }
-       }
-
-       set_bit(EC_FLAGS_HANDLERS_INSTALLED, &ec->flags);
-       return 0;
-}
-
-static int acpi_ec_start(struct acpi_device *device)
-{
-       struct acpi_ec *ec;
-       int ret = 0;
-
-       if (!device)
-               return -EINVAL;
-
-       ec = acpi_driver_data(device);
-
-       if (!ec)
-               return -EINVAL;
-
-       ret = ec_install_handlers(ec);
-
-       /* EC is fully operational, allow queries */
-       clear_bit(EC_FLAGS_QUERY_PENDING, &ec->flags);
-       return ret;
-}
-
-static int acpi_ec_stop(struct acpi_device *device, int type)
-{
-       struct acpi_ec *ec;
-       if (!device)
-               return -EINVAL;
-       ec = acpi_driver_data(device);
-       if (!ec)
-               return -EINVAL;
-       ec_remove_handlers(ec);
-
-       return 0;
-}
-
 int __init acpi_boot_ec_enable(void)
 {
        if (!boot_ec || test_bit(EC_FLAGS_HANDLERS_INSTALLED, &boot_ec->flags))
@@ -1027,8 +998,6 @@ static struct acpi_driver acpi_ec_driver = {
        .ops = {
                .add = acpi_ec_add,
                .remove = acpi_ec_remove,
-               .start = acpi_ec_start,
-               .stop = acpi_ec_stop,
                .suspend = acpi_ec_suspend,
                .resume = acpi_ec_resume,
                },