]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/acpi/ec.c
Merge git://git.infradead.org/mtd-2.6
[linux-2.6-omap-h63xx.git] / drivers / acpi / ec.c
index 453ba1e534ef986b9e593579e89ab7d895ec560d..ef42316f89f52452f69192d89894ca9ba64f46ee 100644 (file)
@@ -298,6 +298,18 @@ static int ec_check_ibf0(struct acpi_ec *ec)
        return (status & ACPI_EC_FLAG_IBF) == 0;
 }
 
+static int ec_wait_ibf0(struct acpi_ec *ec)
+{
+       unsigned long delay = jiffies + msecs_to_jiffies(ACPI_EC_DELAY);
+       /* interrupt wait manually if GPE mode is not active */
+       unsigned long timeout = test_bit(EC_FLAGS_GPE_MODE, &ec->flags) ?
+               msecs_to_jiffies(ACPI_EC_DELAY) : msecs_to_jiffies(1);
+       while (time_before(jiffies, delay))
+               if (wait_event_timeout(ec->wait, ec_check_ibf0(ec), timeout))
+                       return 0;
+       return -ETIME;
+}
+
 static int acpi_ec_transaction(struct acpi_ec *ec, struct transaction *t,
                               int force_poll)
 {
@@ -315,8 +327,7 @@ static int acpi_ec_transaction(struct acpi_ec *ec, struct transaction *t,
                        goto unlock;
                }
        }
-       if (!wait_event_timeout(ec->wait, ec_check_ibf0(ec),
-                               msecs_to_jiffies(ACPI_EC_DELAY))) {
+       if (ec_wait_ibf0(ec)) {
                pr_err(PREFIX "input buffer is not empty, "
                                "aborting transaction\n");
                status = -ETIME;
@@ -725,6 +736,7 @@ static acpi_status
 ec_parse_device(acpi_handle handle, u32 Level, void *context, void **retval)
 {
        acpi_status status;
+       unsigned long long tmp;
 
        struct acpi_ec *ec = context;
        status = acpi_walk_resources(handle, METHOD_NAME__CRS,
@@ -734,11 +746,13 @@ ec_parse_device(acpi_handle handle, u32 Level, void *context, void **retval)
 
        /* Get GPE bit assignment (EC events). */
        /* TODO: Add support for _GPE returning a package */
-       status = acpi_evaluate_integer(handle, "_GPE", NULL, &ec->gpe);
+       status = acpi_evaluate_integer(handle, "_GPE", NULL, &tmp);
        if (ACPI_FAILURE(status))
                return status;
+       ec->gpe = tmp;
        /* Use the global lock for all EC transactions? */
-       acpi_evaluate_integer(handle, "_GLK", NULL, &ec->global_lock);
+       acpi_evaluate_integer(handle, "_GLK", NULL, &tmp);
+       ec->global_lock = tmp;
        ec->handle = handle;
        return AE_CTRL_TERMINATE;
 }
@@ -788,7 +802,7 @@ static int acpi_ec_add(struct acpi_device *device)
 
        if (!first_ec)
                first_ec = ec;
-       acpi_driver_data(device) = ec;
+       device->driver_data = ec;
        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);
@@ -813,7 +827,7 @@ static int acpi_ec_remove(struct acpi_device *device, int type)
        }
        mutex_unlock(&ec->lock);
        acpi_ec_remove_fs(device);
-       acpi_driver_data(device) = NULL;
+       device->driver_data = NULL;
        if (ec == first_ec)
                first_ec = NULL;
        kfree(ec);
@@ -860,8 +874,19 @@ static int ec_install_handlers(struct acpi_ec *ec)
                                                    &acpi_ec_space_handler,
                                                    NULL, ec);
        if (ACPI_FAILURE(status)) {
-               acpi_remove_gpe_handler(NULL, ec->gpe, &acpi_ec_gpe_handler);
-               return -ENODEV;
+               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);