@@ -71,13 +71,16 @@ struct surface_button {
bool suspended;
};
-static void surface_button_notify(struct acpi_device *device, u32 event)
+static void surface_button_notify(acpi_handle handle, u32 event, void *data)
{
- struct surface_button *button = acpi_driver_data(device);
- struct input_dev *input;
+ struct acpi_device *device = data;
+ struct surface_button *button;
int key_code = KEY_RESERVED;
+ struct input_dev *input;
bool pressed = false;
+ button = acpi_driver_data(device);
+
switch (event) {
/* Power button press,release handle */
case SURFACE_BUTTON_NOTIFY_PRESS_POWER:
@@ -230,7 +233,13 @@ static int surface_button_add(struct acpi_device *device)
device_init_wakeup(&device->dev, true);
dev_info(&device->dev,
"%s [%s]\n", name, acpi_device_bid(device));
- return 0;
+
+ error = acpi_device_install_event_handler(device, ACPI_DEVICE_NOTIFY,
+ surface_button_notify);
+ if (error)
+ goto err_free_input;
+
+ return error;
err_free_input:
input_free_device(input);
@@ -243,6 +252,7 @@ static void surface_button_remove(struct acpi_device *device)
{
struct surface_button *button = acpi_driver_data(device);
+ acpi_device_remove_event_handler(device, ACPI_DEVICE_NOTIFY, surface_button_notify);
input_unregister_device(button->input);
kfree(button);
}
@@ -257,7 +267,6 @@ static struct acpi_driver surface_button_driver = {
.ops = {
.add = surface_button_add,
.remove = surface_button_remove,
- .notify = surface_button_notify,
},
.drv.pm = &surface_button_pm,
};
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/platform/surface/surfacepro3_button.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-)