aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjorn Helgaas <bjorn.helgaas@hp.com>2009-04-07 11:37:27 -0400
committerLen Brown <len.brown@intel.com>2009-04-07 16:26:58 -0400
commitcddd1f71d972a43c88f0ef91e1b71023539cd6e0 (patch)
treeaf5a7a62373b3bedd1eaff9364fa15d9c4d55171
parentb4ec0275464756f4fd4108b4a4ca7aff61358ad3 (diff)
panasonic-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. Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com> CC: Harald Welte <laforge@gnumonks.org> Signed-off-by: Len Brown <len.brown@intel.com>
-rw-r--r--drivers/platform/x86/panasonic-laptop.c26
1 files changed, 5 insertions, 21 deletions
diff --git a/drivers/platform/x86/panasonic-laptop.c b/drivers/platform/x86/panasonic-laptop.c
index a5ce4bc202e3..1a11de0d3e6d 100644
--- a/drivers/platform/x86/panasonic-laptop.c
+++ b/drivers/platform/x86/panasonic-laptop.c
@@ -176,6 +176,7 @@ enum SINF_BITS { SINF_NUM_BATTERIES = 0,
176static int acpi_pcc_hotkey_add(struct acpi_device *device); 176static int acpi_pcc_hotkey_add(struct acpi_device *device);
177static int acpi_pcc_hotkey_remove(struct acpi_device *device, int type); 177static int acpi_pcc_hotkey_remove(struct acpi_device *device, int type);
178static int acpi_pcc_hotkey_resume(struct acpi_device *device); 178static int acpi_pcc_hotkey_resume(struct acpi_device *device);
179static void acpi_pcc_hotkey_notify(struct acpi_device *device, u32 event);
179 180
180static const struct acpi_device_id pcc_device_ids[] = { 181static const struct acpi_device_id pcc_device_ids[] = {
181 { "MAT0012", 0}, 182 { "MAT0012", 0},
@@ -194,6 +195,7 @@ static struct acpi_driver acpi_pcc_driver = {
194 .add = acpi_pcc_hotkey_add, 195 .add = acpi_pcc_hotkey_add,
195 .remove = acpi_pcc_hotkey_remove, 196 .remove = acpi_pcc_hotkey_remove,
196 .resume = acpi_pcc_hotkey_resume, 197 .resume = acpi_pcc_hotkey_resume,
198 .notify = acpi_pcc_hotkey_notify,
197 }, 199 },
198}; 200};
199 201
@@ -527,9 +529,9 @@ static void acpi_pcc_generate_keyinput(struct pcc_acpi *pcc)
527 return; 529 return;
528} 530}
529 531
530static void acpi_pcc_hotkey_notify(acpi_handle handle, u32 event, void *data) 532static void acpi_pcc_hotkey_notify(struct acpi_device *device, u32 event)
531{ 533{
532 struct pcc_acpi *pcc = (struct pcc_acpi *) data; 534 struct pcc_acpi *pcc = acpi_driver_data(device);
533 535
534 switch (event) { 536 switch (event) {
535 case HKEY_NOTIFY: 537 case HKEY_NOTIFY:
@@ -599,7 +601,6 @@ static int acpi_pcc_hotkey_resume(struct acpi_device *device)
599 601
600static int acpi_pcc_hotkey_add(struct acpi_device *device) 602static int acpi_pcc_hotkey_add(struct acpi_device *device)
601{ 603{
602 acpi_status status;
603 struct pcc_acpi *pcc; 604 struct pcc_acpi *pcc;
604 int num_sifr, result; 605 int num_sifr, result;
605 606
@@ -640,22 +641,11 @@ static int acpi_pcc_hotkey_add(struct acpi_device *device)
640 goto out_sinf; 641 goto out_sinf;
641 } 642 }
642 643
643 /* initialize hotkey input device */
644 status = acpi_install_notify_handler(pcc->handle, ACPI_DEVICE_NOTIFY,
645 acpi_pcc_hotkey_notify, pcc);
646
647 if (ACPI_FAILURE(status)) {
648 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
649 "Error installing notify handler\n"));
650 result = -ENODEV;
651 goto out_input;
652 }
653
654 /* initialize backlight */ 644 /* initialize backlight */
655 pcc->backlight = backlight_device_register("panasonic", NULL, pcc, 645 pcc->backlight = backlight_device_register("panasonic", NULL, pcc,
656 &pcc_backlight_ops); 646 &pcc_backlight_ops);
657 if (IS_ERR(pcc->backlight)) 647 if (IS_ERR(pcc->backlight))
658 goto out_notify; 648 goto out_input;
659 649
660 if (!acpi_pcc_retrieve_biosdata(pcc, pcc->sinf)) { 650 if (!acpi_pcc_retrieve_biosdata(pcc, pcc->sinf)) {
661 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 651 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
@@ -680,9 +670,6 @@ static int acpi_pcc_hotkey_add(struct acpi_device *device)
680 670
681out_backlight: 671out_backlight:
682 backlight_device_unregister(pcc->backlight); 672 backlight_device_unregister(pcc->backlight);
683out_notify:
684 acpi_remove_notify_handler(pcc->handle, ACPI_DEVICE_NOTIFY,
685 acpi_pcc_hotkey_notify);
686out_input: 673out_input:
687 input_unregister_device(pcc->input_dev); 674 input_unregister_device(pcc->input_dev);
688 /* no need to input_free_device() since core input API refcount and 675 /* no need to input_free_device() since core input API refcount and
@@ -723,9 +710,6 @@ static int acpi_pcc_hotkey_remove(struct acpi_device *device, int type)
723 710
724 backlight_device_unregister(pcc->backlight); 711 backlight_device_unregister(pcc->backlight);
725 712
726 acpi_remove_notify_handler(pcc->handle, ACPI_DEVICE_NOTIFY,
727 acpi_pcc_hotkey_notify);
728
729 input_unregister_device(pcc->input_dev); 713 input_unregister_device(pcc->input_dev);
730 /* no need to input_free_device() since core input API refcount and 714 /* no need to input_free_device() since core input API refcount and
731 * free()s the device */ 715 * free()s the device */