@@ -126,7 +126,7 @@ static const struct dmi_system_id dmi_lid_quirks[] = {
static int acpi_button_add(struct acpi_device *device);
static void acpi_button_remove(struct acpi_device *device);
-static void acpi_button_notify(struct acpi_device *device, u32 event);
+static void acpi_button_notify(acpi_handle handle, u32 event, void *data);
#ifdef CONFIG_PM_SLEEP
static int acpi_button_suspend(struct device *dev);
@@ -144,7 +144,6 @@ static struct acpi_driver acpi_button_driver = {
.ops = {
.add = acpi_button_add,
.remove = acpi_button_remove,
- .notify = acpi_button_notify,
},
.drv.pm = &acpi_button_pm,
};
@@ -400,11 +399,14 @@ static void acpi_lid_initialize_state(struct acpi_device *device)
button->lid_state_initialized = true;
}
-static void acpi_button_notify(struct acpi_device *device, u32 event)
+static void acpi_button_notify(acpi_handle handle, u32 event, void *data)
{
- struct acpi_button *button = acpi_driver_data(device);
+ struct acpi_device *device = data;
+ struct acpi_button *button;
struct input_dev *input;
+ button = acpi_driver_data(device);
+
switch (event) {
case ACPI_FIXED_HARDWARE_EVENT:
event = ACPI_BUTTON_NOTIFY_STATUS;
@@ -569,7 +571,12 @@ static int acpi_button_add(struct acpi_device *device)
device_init_wakeup(&device->dev, true);
pr_info("%s [%s]\n", name, acpi_device_bid(device));
- return 0;
+
+ error = acpi_device_install_event_handler(device, ACPI_DEVICE_NOTIFY, acpi_button_notify);
+ if (error)
+ goto err_remove_fs;
+
+ return error;
err_remove_fs:
acpi_button_remove_fs(device);
@@ -584,6 +591,7 @@ static void acpi_button_remove(struct acpi_device *device)
{
struct acpi_button *button = acpi_driver_data(device);
+ acpi_device_remove_event_handler(device, ACPI_DEVICE_NOTIFY, acpi_button_notify);
acpi_button_remove_fs(device);
input_unregister_device(button->input);
kfree(button);
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> --- drivers/acpi/button.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-)