ACPI: EC: Fix EC address space handler unregistration
authorHans de Goede <hdegoede@redhat.com>
Thu, 8 Dec 2022 14:23:34 +0000 (15:23 +0100)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Thu, 8 Dec 2022 16:42:12 +0000 (17:42 +0100)
When an ECDT table is present the EC address space handler gets registered
on the root node. So to unregister it properly the unregister call also
must be done on the root node.

Store the ACPI handle used for the acpi_install_address_space_handler()
call and use te same handle for the acpi_remove_address_space_handler()
call.

Reported-by: Rafael J. Wysocki <rafael@kernel.org>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/acpi/ec.c
drivers/acpi/internal.h

index 9751b84c1b22193bf75e551a91f018ce8463573a..5a21e4d58322bc6bc1f4cf97977d90833c49cb39 100644 (file)
@@ -1475,6 +1475,7 @@ static int ec_install_handlers(struct acpi_ec *ec, struct acpi_device *device)
                        return -ENODEV;
                }
                set_bit(EC_FLAGS_EC_HANDLER_INSTALLED, &ec->flags);
+               ec->address_space_handler_holder = ec->handle;
        }
 
        if (!device)
@@ -1526,7 +1527,8 @@ static int ec_install_handlers(struct acpi_ec *ec, struct acpi_device *device)
 static void ec_remove_handlers(struct acpi_ec *ec)
 {
        if (test_bit(EC_FLAGS_EC_HANDLER_INSTALLED, &ec->flags)) {
-               if (ACPI_FAILURE(acpi_remove_address_space_handler(ec->handle,
+               if (ACPI_FAILURE(acpi_remove_address_space_handler(
+                                       ec->address_space_handler_holder,
                                        ACPI_ADR_SPACE_EC, &acpi_ec_space_handler)))
                        pr_err("failed to remove space handler\n");
                clear_bit(EC_FLAGS_EC_HANDLER_INSTALLED, &ec->flags);
index 219c02df9a08c720dcca32559f47d3770b0507c2..ec584442fb298861d75b51adafe9732f5ec09290 100644 (file)
@@ -173,6 +173,7 @@ enum acpi_ec_event_state {
 
 struct acpi_ec {
        acpi_handle handle;
+       acpi_handle address_space_handler_holder;
        int gpe;
        int irq;
        unsigned long command_addr;