Skip to content

Commit

Permalink
ACPI: EC: Fix EC address space handler unregistration
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Hans de Goede authored and Rafael J. Wysocki committed Dec 8, 2022
1 parent 0634033 commit a507207
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
4 changes: 3 additions & 1 deletion drivers/acpi/ec.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions drivers/acpi/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit a507207

Please sign in to comment.