Skip to content

Commit

Permalink
acpi/tiny-power-button: Move handler installing logic to driver
Browse files Browse the repository at this point in the history
Currently logic for installing notifications from ACPI devices is
implemented using notify callback in struct acpi_driver. Preparations
are being made to replace acpi_driver with more generic struct
platform_driver, which doesn't contain notify callback. Furthermore
as of now handlers are being called indirectly through
acpi_notify_device(), which decreases performance.

Call acpi_device_install_event_handler() at the end of .add() callback.
Call acpi_device_remove_event_handler() at the beginning of .remove()
callback. Change arguments passed to the notify callback to match with
what's required by acpi_device_install_event_handler().

Signed-off-by: Michal Wilczynski <michal.wilczynski@intel.com>
  • Loading branch information
mwilczy authored and intel-lab-lkp committed May 12, 2023
1 parent b3d3c58 commit e12cdb4
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions drivers/acpi/tiny-power-button.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,19 @@ static const struct acpi_device_id tiny_power_button_device_ids[] = {
};
MODULE_DEVICE_TABLE(acpi, tiny_power_button_device_ids);

static int acpi_noop_add(struct acpi_device *device)
static int acpi_tiny_power_button_add(struct acpi_device *device)
{
return 0;
return acpi_device_install_event_handler(device, ACPI_DEVICE_NOTIFY,
acpi_tiny_power_button_notify);
}

static void acpi_noop_remove(struct acpi_device *device)
static void acpi_tiny_power_button_remove(struct acpi_device *device)
{
acpi_device_remove_event_handler(device->handle, ACPI_DEVICE_NOTIFY,
acpi_tiny_power_button_notify);
}

static void acpi_tiny_power_button_notify(struct acpi_device *device, u32 event)
static void acpi_tiny_power_button_notify(acpi_handle handle, u32 event, void *data)
{
kill_cad_pid(power_signal, 1);
}
Expand All @@ -38,9 +41,8 @@ static struct acpi_driver acpi_tiny_power_button_driver = {
.class = "tiny-power-button",
.ids = tiny_power_button_device_ids,
.ops = {
.add = acpi_noop_add,
.remove = acpi_noop_remove,
.notify = acpi_tiny_power_button_notify,
.add = acpi_tiny_power_button_add,
.remove = acpi_tiny_power_button_remove,
},
};

Expand Down

0 comments on commit e12cdb4

Please sign in to comment.