Commit e4e62d5f authored by Rafael J. Wysocki's avatar Rafael J. Wysocki

ACPI: button: Use different notify handlers for lid and buttons

Since the lid handling in acpi_button_notify() is special, introduce
acpi_lid_notify() specifically for handling lid notifications.
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
parent 0d51157d
...@@ -398,12 +398,10 @@ static void acpi_lid_initialize_state(struct acpi_device *device) ...@@ -398,12 +398,10 @@ static void acpi_lid_initialize_state(struct acpi_device *device)
button->lid_state_initialized = true; button->lid_state_initialized = true;
} }
static void acpi_button_notify(acpi_handle handle, u32 event, void *data) static void acpi_lid_notify(acpi_handle handle, u32 event, void *data)
{ {
struct acpi_device *device = data; struct acpi_device *device = data;
struct acpi_button *button; struct acpi_button *button;
struct input_dev *input;
int keycode;
if (event != ACPI_BUTTON_NOTIFY_STATUS) { if (event != ACPI_BUTTON_NOTIFY_STATUS) {
acpi_handle_debug(device->handle, "Unsupported event [0x%x]\n", acpi_handle_debug(device->handle, "Unsupported event [0x%x]\n",
...@@ -412,16 +410,28 @@ static void acpi_button_notify(acpi_handle handle, u32 event, void *data) ...@@ -412,16 +410,28 @@ static void acpi_button_notify(acpi_handle handle, u32 event, void *data)
} }
button = acpi_driver_data(device); button = acpi_driver_data(device);
if (!button->lid_state_initialized)
return;
if (button->type == ACPI_BUTTON_TYPE_LID) {
if (button->lid_state_initialized)
acpi_lid_update_state(device, true); acpi_lid_update_state(device, true);
}
static void acpi_button_notify(acpi_handle handle, u32 event, void *data)
{
struct acpi_device *device = data;
struct acpi_button *button;
struct input_dev *input;
int keycode;
if (event != ACPI_BUTTON_NOTIFY_STATUS) {
acpi_handle_debug(device->handle, "Unsupported event [0x%x]\n",
event);
return; return;
} }
acpi_pm_wakeup_event(&device->dev); acpi_pm_wakeup_event(&device->dev);
button = acpi_driver_data(device);
if (button->suspended) if (button->suspended)
return; return;
...@@ -488,6 +498,7 @@ static int acpi_lid_input_open(struct input_dev *input) ...@@ -488,6 +498,7 @@ static int acpi_lid_input_open(struct input_dev *input)
static int acpi_button_add(struct acpi_device *device) static int acpi_button_add(struct acpi_device *device)
{ {
acpi_notify_handler handler;
struct acpi_button *button; struct acpi_button *button;
struct input_dev *input; struct input_dev *input;
const char *hid = acpi_device_hid(device); const char *hid = acpi_device_hid(device);
...@@ -517,17 +528,20 @@ static int acpi_button_add(struct acpi_device *device) ...@@ -517,17 +528,20 @@ static int acpi_button_add(struct acpi_device *device)
if (!strcmp(hid, ACPI_BUTTON_HID_POWER) || if (!strcmp(hid, ACPI_BUTTON_HID_POWER) ||
!strcmp(hid, ACPI_BUTTON_HID_POWERF)) { !strcmp(hid, ACPI_BUTTON_HID_POWERF)) {
button->type = ACPI_BUTTON_TYPE_POWER; button->type = ACPI_BUTTON_TYPE_POWER;
handler = acpi_button_notify;
strcpy(name, ACPI_BUTTON_DEVICE_NAME_POWER); strcpy(name, ACPI_BUTTON_DEVICE_NAME_POWER);
sprintf(class, "%s/%s", sprintf(class, "%s/%s",
ACPI_BUTTON_CLASS, ACPI_BUTTON_SUBCLASS_POWER); ACPI_BUTTON_CLASS, ACPI_BUTTON_SUBCLASS_POWER);
} else if (!strcmp(hid, ACPI_BUTTON_HID_SLEEP) || } else if (!strcmp(hid, ACPI_BUTTON_HID_SLEEP) ||
!strcmp(hid, ACPI_BUTTON_HID_SLEEPF)) { !strcmp(hid, ACPI_BUTTON_HID_SLEEPF)) {
button->type = ACPI_BUTTON_TYPE_SLEEP; button->type = ACPI_BUTTON_TYPE_SLEEP;
handler = acpi_button_notify;
strcpy(name, ACPI_BUTTON_DEVICE_NAME_SLEEP); strcpy(name, ACPI_BUTTON_DEVICE_NAME_SLEEP);
sprintf(class, "%s/%s", sprintf(class, "%s/%s",
ACPI_BUTTON_CLASS, ACPI_BUTTON_SUBCLASS_SLEEP); ACPI_BUTTON_CLASS, ACPI_BUTTON_SUBCLASS_SLEEP);
} else if (!strcmp(hid, ACPI_BUTTON_HID_LID)) { } else if (!strcmp(hid, ACPI_BUTTON_HID_LID)) {
button->type = ACPI_BUTTON_TYPE_LID; button->type = ACPI_BUTTON_TYPE_LID;
handler = acpi_lid_notify;
strcpy(name, ACPI_BUTTON_DEVICE_NAME_LID); strcpy(name, ACPI_BUTTON_DEVICE_NAME_LID);
sprintf(class, "%s/%s", sprintf(class, "%s/%s",
ACPI_BUTTON_CLASS, ACPI_BUTTON_SUBCLASS_LID); ACPI_BUTTON_CLASS, ACPI_BUTTON_SUBCLASS_LID);
...@@ -585,8 +599,7 @@ static int acpi_button_add(struct acpi_device *device) ...@@ -585,8 +599,7 @@ static int acpi_button_add(struct acpi_device *device)
break; break;
default: default:
status = acpi_install_notify_handler(device->handle, status = acpi_install_notify_handler(device->handle,
ACPI_DEVICE_NOTIFY, ACPI_DEVICE_NOTIFY, handler,
acpi_button_notify,
device); device);
break; break;
} }
...@@ -631,6 +644,8 @@ static void acpi_button_remove(struct acpi_device *device) ...@@ -631,6 +644,8 @@ static void acpi_button_remove(struct acpi_device *device)
break; break;
default: default:
acpi_remove_notify_handler(device->handle, ACPI_DEVICE_NOTIFY, acpi_remove_notify_handler(device->handle, ACPI_DEVICE_NOTIFY,
button->type == ACPI_BUTTON_TYPE_LID ?
acpi_lid_notify :
acpi_button_notify); acpi_button_notify);
break; break;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment