diff options
author | Bjorn Helgaas <bjorn.helgaas@hp.com> | 2009-04-30 11:36:03 -0400 |
---|---|---|
committer | Len Brown <len.brown@intel.com> | 2009-06-18 00:13:15 -0400 |
commit | d9b9bd7b4a579ff0340d29c2547b952a920639e6 (patch) | |
tree | b7ce0c476949b42880e5522993693a4d5a9cbc91 | |
parent | 352fa202c3320ac4844cd38fa72c7a91d7c4cfea (diff) |
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: Bjorn 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: Len Brown <len.brown@intel.com>
-rw-r--r-- | drivers/platform/x86/eeepc-laptop.c | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/drivers/platform/x86/eeepc-laptop.c b/drivers/platform/x86/eeepc-laptop.c index 353a898c3693..1e28413060b2 100644 --- a/drivers/platform/x86/eeepc-laptop.c +++ b/drivers/platform/x86/eeepc-laptop.c | |||
@@ -180,6 +180,7 @@ static struct key_entry eeepc_keymap[] = { | |||
180 | */ | 180 | */ |
181 | static int eeepc_hotk_add(struct acpi_device *device); | 181 | static int eeepc_hotk_add(struct acpi_device *device); |
182 | static int eeepc_hotk_remove(struct acpi_device *device, int type); | 182 | static int eeepc_hotk_remove(struct acpi_device *device, int type); |
183 | static void eeepc_hotk_notify(struct acpi_device *device, u32 event); | ||
183 | 184 | ||
184 | static const struct acpi_device_id eeepc_device_ids[] = { | 185 | static const struct acpi_device_id eeepc_device_ids[] = { |
185 | {EEEPC_HOTK_HID, 0}, | 186 | {EEEPC_HOTK_HID, 0}, |
@@ -191,9 +192,11 @@ static struct acpi_driver eeepc_hotk_driver = { | |||
191 | .name = EEEPC_HOTK_NAME, | 192 | .name = EEEPC_HOTK_NAME, |
192 | .class = EEEPC_HOTK_CLASS, | 193 | .class = EEEPC_HOTK_CLASS, |
193 | .ids = eeepc_device_ids, | 194 | .ids = eeepc_device_ids, |
195 | .flags = ACPI_DRIVER_ALL_NOTIFY_EVENTS, | ||
194 | .ops = { | 196 | .ops = { |
195 | .add = eeepc_hotk_add, | 197 | .add = eeepc_hotk_add, |
196 | .remove = eeepc_hotk_remove, | 198 | .remove = eeepc_hotk_remove, |
199 | .notify = eeepc_hotk_notify, | ||
197 | }, | 200 | }, |
198 | }; | 201 | }; |
199 | 202 | ||
@@ -569,7 +572,7 @@ static void eeepc_rfkill_notify(acpi_handle handle, u32 event, void *data) | |||
569 | rfkill_force_state(ehotk->eeepc_wlan_rfkill, state); | 572 | rfkill_force_state(ehotk->eeepc_wlan_rfkill, state); |
570 | } | 573 | } |
571 | 574 | ||
572 | static void eeepc_hotk_notify(acpi_handle handle, u32 event, void *data) | 575 | static void eeepc_hotk_notify(struct acpi_device *device, u32 event) |
573 | { | 576 | { |
574 | static struct key_entry *key; | 577 | static struct key_entry *key; |
575 | u16 count; | 578 | u16 count; |
@@ -577,6 +580,8 @@ static void eeepc_hotk_notify(acpi_handle handle, u32 event, void *data) | |||
577 | 580 | ||
578 | if (!ehotk) | 581 | if (!ehotk) |
579 | return; | 582 | return; |
583 | if (event > ACPI_MAX_SYS_NOTIFY) | ||
584 | return; | ||
580 | if (event >= NOTIFY_BRN_MIN && event <= NOTIFY_BRN_MAX) | 585 | if (event >= NOTIFY_BRN_MIN && event <= NOTIFY_BRN_MAX) |
581 | brn = notify_brn(); | 586 | brn = notify_brn(); |
582 | count = ehotk->event_count[event % 128]++; | 587 | count = ehotk->event_count[event % 128]++; |
@@ -657,7 +662,6 @@ static void eeepc_unregister_rfkill_notifier(char *node) | |||
657 | 662 | ||
658 | static int eeepc_hotk_add(struct acpi_device *device) | 663 | static int eeepc_hotk_add(struct acpi_device *device) |
659 | { | 664 | { |
660 | acpi_status status = AE_OK; | ||
661 | int result; | 665 | int result; |
662 | 666 | ||
663 | if (!device) | 667 | if (!device) |
@@ -675,10 +679,6 @@ static int eeepc_hotk_add(struct acpi_device *device) | |||
675 | result = eeepc_hotk_check(); | 679 | result = eeepc_hotk_check(); |
676 | if (result) | 680 | if (result) |
677 | goto ehotk_fail; | 681 | goto ehotk_fail; |
678 | status = acpi_install_notify_handler(ehotk->handle, ACPI_SYSTEM_NOTIFY, | ||
679 | eeepc_hotk_notify, ehotk); | ||
680 | if (ACPI_FAILURE(status)) | ||
681 | printk(EEEPC_ERR "Error installing notify handler\n"); | ||
682 | 682 | ||
683 | eeepc_register_rfkill_notifier("\\_SB.PCI0.P0P6"); | 683 | eeepc_register_rfkill_notifier("\\_SB.PCI0.P0P6"); |
684 | eeepc_register_rfkill_notifier("\\_SB.PCI0.P0P7"); | 684 | eeepc_register_rfkill_notifier("\\_SB.PCI0.P0P7"); |
@@ -759,14 +759,8 @@ static int eeepc_hotk_add(struct acpi_device *device) | |||
759 | 759 | ||
760 | static int eeepc_hotk_remove(struct acpi_device *device, int type) | 760 | static int eeepc_hotk_remove(struct acpi_device *device, int type) |
761 | { | 761 | { |
762 | acpi_status status = 0; | ||
763 | |||
764 | if (!device || !acpi_driver_data(device)) | 762 | if (!device || !acpi_driver_data(device)) |
765 | return -EINVAL; | 763 | return -EINVAL; |
766 | status = acpi_remove_notify_handler(ehotk->handle, ACPI_SYSTEM_NOTIFY, | ||
767 | eeepc_hotk_notify); | ||
768 | if (ACPI_FAILURE(status)) | ||
769 | printk(EEEPC_ERR "Error removing notify handler\n"); | ||
770 | 764 | ||
771 | eeepc_unregister_rfkill_notifier("\\_SB.PCI0.P0P6"); | 765 | eeepc_unregister_rfkill_notifier("\\_SB.PCI0.P0P6"); |
772 | eeepc_unregister_rfkill_notifier("\\_SB.PCI0.P0P7"); | 766 | eeepc_unregister_rfkill_notifier("\\_SB.PCI0.P0P7"); |