+ mutex_init(&ec_ecdt->lock);
+ if (acpi_ec_mode == EC_INTR) {
+ init_waitqueue_head(&ec_ecdt->wait);
+ }
+ status = acpi_walk_resources(handle, METHOD_NAME__CRS,
+ acpi_ec_io_ports, ec_ecdt);
+ if (ACPI_FAILURE(status))
+ return status;
+
+ ec_ecdt->uid = -1;
+ acpi_evaluate_integer(handle, "_UID", NULL, &ec_ecdt->uid);
+
+ status = acpi_evaluate_integer(handle, "_GPE", NULL, &ec_ecdt->gpe);
+ if (ACPI_FAILURE(status))
+ return status;
+ ec_ecdt->global_lock = TRUE;
+ ec_ecdt->handle = handle;
+
+ ACPI_DEBUG_PRINT((ACPI_DB_INFO, "GPE=0x%02lx, ports=0x%2lx, 0x%2lx",
+ ec_ecdt->gpe, ec_ecdt->command_addr,
+ ec_ecdt->data_addr));
+
+ return AE_CTRL_TERMINATE;
+}
+
+/*
+ * Some BIOS (such as some from Gateway laptops) access EC region very early
+ * such as in BAT0._INI or EC._INI before an EC device is found and
+ * do not provide an ECDT. According to ACPI spec, ECDT isn't mandatorily
+ * required, but if EC regison is accessed early, it is required.
+ * The routine tries to workaround the BIOS bug by pre-scan EC device
+ * It assumes that _CRS, _HID, _GPE, _UID methods of EC don't touch any
+ * op region (since _REG isn't invoked yet). The assumption is true for
+ * all systems found.
+ */
+static int __init acpi_ec_fake_ecdt(void)
+{
+ acpi_status status;
+ int ret = 0;
+
+ ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Try to make an fake ECDT"));
+
+ ec_ecdt = kzalloc(sizeof(struct acpi_ec), GFP_KERNEL);
+ if (!ec_ecdt) {
+ ret = -ENOMEM;
+ goto error;
+ }
+
+ status = acpi_get_devices(ACPI_EC_HID,
+ acpi_fake_ecdt_callback, NULL, NULL);
+ if (ACPI_FAILURE(status)) {
+ kfree(ec_ecdt);
+ ec_ecdt = NULL;
+ ret = -ENODEV;
+ ACPI_EXCEPTION((AE_INFO, status, "Can't make an fake ECDT"));
+ goto error;
+ }
+ return 0;
+ error:
+ return ret;
+}
+
+static int __init acpi_ec_get_real_ecdt(void)