[ISDN] HiSax sedlbauer: move ISAPNP and PCI code into functions of their own
[firefly-linux-kernel-4.4.55.git] / drivers / acpi / ec.c
index 629289034b613f1439ed9067582c0e8f622c2cf1..3f7935ab0cf53c0d6ca21b89096ba3c727e0e7b6 100644 (file)
@@ -651,6 +651,19 @@ static struct acpi_ec *make_acpi_ec(void)
        return ec;
 }
 
+static acpi_status
+acpi_ec_register_query_methods(acpi_handle handle, u32 level,
+                              void *context, void **return_value)
+{
+       struct acpi_namespace_node *node = handle;
+       struct acpi_ec *ec = context;
+       int value = 0;
+       if (sscanf(node->name.ascii, "_Q%x", &value) == 1) {
+               acpi_ec_add_query_handler(ec, value, handle, NULL, NULL);
+       }
+       return AE_OK;
+}
+
 static acpi_status
 ec_parse_device(acpi_handle handle, u32 Level, void *context, void **retval)
 {
@@ -668,12 +681,16 @@ ec_parse_device(acpi_handle handle, u32 Level, void *context, void **retval)
        if (ACPI_FAILURE(status))
                return status;
 
+       /* Find and register all query methods */
+       acpi_walk_namespace(ACPI_TYPE_METHOD, handle, 1,
+                           acpi_ec_register_query_methods, ec, NULL);
+
        /* Use the global lock for all EC transactions? */
        acpi_evaluate_integer(handle, "_GLK", NULL, &ec->global_lock);
 
        ec->handle = handle;
 
-       printk(KERN_INFO PREFIX "GPE = 0x%lx, I/O: command/status = 0x%lx, data = 0x%lx",
+       printk(KERN_INFO PREFIX "GPE = 0x%lx, I/O: command/status = 0x%lx, data = 0x%lx\n",
                          ec->gpe, ec->command_addr, ec->data_addr);
 
        return AE_CTRL_TERMINATE;
@@ -723,14 +740,14 @@ static int acpi_ec_add(struct acpi_device *device)
 static int acpi_ec_remove(struct acpi_device *device, int type)
 {
        struct acpi_ec *ec;
-       struct acpi_ec_query_handler *handler;
+       struct acpi_ec_query_handler *handler, *tmp;
 
        if (!device)
                return -EINVAL;
 
        ec = acpi_driver_data(device);
        mutex_lock(&ec->lock);
-       list_for_each_entry(handler, &ec->list, node) {
+       list_for_each_entry_safe(handler, tmp, &ec->list, node) {
                list_del(&handler->node);
                kfree(handler);
        }
@@ -869,7 +886,8 @@ int __init acpi_ec_ecdt_probe(void)
                printk(KERN_DEBUG PREFIX "Look up EC in DSDT\n");
                status = acpi_get_devices(ec_device_ids[0].id, ec_parse_device,
                                                boot_ec, NULL);
-               if (ACPI_FAILURE(status))
+               /* Check that acpi_get_devices actually find something */
+               if (ACPI_FAILURE(status) || !boot_ec->handle)
                        goto error;
        }