Commit d9b9bd7b authored by Bjorn Helgaas's avatar Bjorn Helgaas Committed by Len Brown

ACPI: eeepc-laptop: use .notify method instead of installing handler directly

This patch adds a .notify() method.  The presence of .notify() causes
Linux/ACPI to manage event handlers and notify handlers on our behalf,
so we don't have to install and remove them ourselves.

This driver relies on seeing system notify events, not device-specific
ones (because it used ACPI_SYSTEM_NOTIFY).  We use the
ACPI_DRIVER_ALL_NOTIFY_EVENTS driver flag to request all events, then
just ignore any device events we get.
Signed-off-by: default avatarBjorn Helgaas <bjorn.helgaas@hp.com>
CC: Corentin Chary <corentincj@iksaif.net>
CC: acpi4asus-user@lists.sourceforge.net
CC: Matthew Garrett <mjg@redhat.com>
Signed-off-by: default avatarLen Brown <len.brown@intel.com>
parent 352fa202
...@@ -180,6 +180,7 @@ static struct key_entry eeepc_keymap[] = { ...@@ -180,6 +180,7 @@ static struct key_entry eeepc_keymap[] = {
*/ */
static int eeepc_hotk_add(struct acpi_device *device); static int eeepc_hotk_add(struct acpi_device *device);
static int eeepc_hotk_remove(struct acpi_device *device, int type); static int eeepc_hotk_remove(struct acpi_device *device, int type);
static void eeepc_hotk_notify(struct acpi_device *device, u32 event);
static const struct acpi_device_id eeepc_device_ids[] = { static const struct acpi_device_id eeepc_device_ids[] = {
{EEEPC_HOTK_HID, 0}, {EEEPC_HOTK_HID, 0},
...@@ -191,9 +192,11 @@ static struct acpi_driver eeepc_hotk_driver = { ...@@ -191,9 +192,11 @@ static struct acpi_driver eeepc_hotk_driver = {
.name = EEEPC_HOTK_NAME, .name = EEEPC_HOTK_NAME,
.class = EEEPC_HOTK_CLASS, .class = EEEPC_HOTK_CLASS,
.ids = eeepc_device_ids, .ids = eeepc_device_ids,
.flags = ACPI_DRIVER_ALL_NOTIFY_EVENTS,
.ops = { .ops = {
.add = eeepc_hotk_add, .add = eeepc_hotk_add,
.remove = eeepc_hotk_remove, .remove = eeepc_hotk_remove,
.notify = eeepc_hotk_notify,
}, },
}; };
...@@ -569,7 +572,7 @@ static void eeepc_rfkill_notify(acpi_handle handle, u32 event, void *data) ...@@ -569,7 +572,7 @@ static void eeepc_rfkill_notify(acpi_handle handle, u32 event, void *data)
rfkill_force_state(ehotk->eeepc_wlan_rfkill, state); rfkill_force_state(ehotk->eeepc_wlan_rfkill, state);
} }
static void eeepc_hotk_notify(acpi_handle handle, u32 event, void *data) static void eeepc_hotk_notify(struct acpi_device *device, u32 event)
{ {
static struct key_entry *key; static struct key_entry *key;
u16 count; u16 count;
...@@ -577,6 +580,8 @@ static void eeepc_hotk_notify(acpi_handle handle, u32 event, void *data) ...@@ -577,6 +580,8 @@ static void eeepc_hotk_notify(acpi_handle handle, u32 event, void *data)
if (!ehotk) if (!ehotk)
return; return;
if (event > ACPI_MAX_SYS_NOTIFY)
return;
if (event >= NOTIFY_BRN_MIN && event <= NOTIFY_BRN_MAX) if (event >= NOTIFY_BRN_MIN && event <= NOTIFY_BRN_MAX)
brn = notify_brn(); brn = notify_brn();
count = ehotk->event_count[event % 128]++; count = ehotk->event_count[event % 128]++;
...@@ -657,7 +662,6 @@ static void eeepc_unregister_rfkill_notifier(char *node) ...@@ -657,7 +662,6 @@ static void eeepc_unregister_rfkill_notifier(char *node)
static int eeepc_hotk_add(struct acpi_device *device) static int eeepc_hotk_add(struct acpi_device *device)
{ {
acpi_status status = AE_OK;
int result; int result;
if (!device) if (!device)
...@@ -675,10 +679,6 @@ static int eeepc_hotk_add(struct acpi_device *device) ...@@ -675,10 +679,6 @@ static int eeepc_hotk_add(struct acpi_device *device)
result = eeepc_hotk_check(); result = eeepc_hotk_check();
if (result) if (result)
goto ehotk_fail; goto ehotk_fail;
status = acpi_install_notify_handler(ehotk->handle, ACPI_SYSTEM_NOTIFY,
eeepc_hotk_notify, ehotk);
if (ACPI_FAILURE(status))
printk(EEEPC_ERR "Error installing notify handler\n");
eeepc_register_rfkill_notifier("\\_SB.PCI0.P0P6"); eeepc_register_rfkill_notifier("\\_SB.PCI0.P0P6");
eeepc_register_rfkill_notifier("\\_SB.PCI0.P0P7"); eeepc_register_rfkill_notifier("\\_SB.PCI0.P0P7");
...@@ -759,14 +759,8 @@ static int eeepc_hotk_add(struct acpi_device *device) ...@@ -759,14 +759,8 @@ static int eeepc_hotk_add(struct acpi_device *device)
static int eeepc_hotk_remove(struct acpi_device *device, int type) static int eeepc_hotk_remove(struct acpi_device *device, int type)
{ {
acpi_status status = 0;
if (!device || !acpi_driver_data(device)) if (!device || !acpi_driver_data(device))
return -EINVAL; return -EINVAL;
status = acpi_remove_notify_handler(ehotk->handle, ACPI_SYSTEM_NOTIFY,
eeepc_hotk_notify);
if (ACPI_FAILURE(status))
printk(EEEPC_ERR "Error removing notify handler\n");
eeepc_unregister_rfkill_notifier("\\_SB.PCI0.P0P6"); eeepc_unregister_rfkill_notifier("\\_SB.PCI0.P0P6");
eeepc_unregister_rfkill_notifier("\\_SB.PCI0.P0P7"); eeepc_unregister_rfkill_notifier("\\_SB.PCI0.P0P7");
......
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