fujitsu-laptop: use .notify method instead of installing hotkey 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. Tested by Tony on Fujitsu-Siemens Lifebook S6420 [FJNB1E6] with BIOS 1.18 (01/09/2009). Tested by Jonathan on Fujitsu S7020. Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com> Acked-By: Tony Vroon <tony@linx.net> Tested-By: Tony Vroon <tony@linx.net> Acked-by: Jonathan Woithe <jwoithe@physics.adelaide.edu.au> Tested-by: Jonathan Woithe <jwoithe@physics.adelaide.edu.au> Signed-off-by: Len Brown <len.brown@intel.com>
This commit is contained in:
@@ -174,8 +174,7 @@ struct fujitsu_hotkey_t {
|
|||||||
|
|
||||||
static struct fujitsu_hotkey_t *fujitsu_hotkey;
|
static struct fujitsu_hotkey_t *fujitsu_hotkey;
|
||||||
|
|
||||||
static void acpi_fujitsu_hotkey_notify(acpi_handle handle, u32 event,
|
static void acpi_fujitsu_hotkey_notify(struct acpi_device *device, u32 event);
|
||||||
void *data);
|
|
||||||
|
|
||||||
#ifdef CONFIG_LEDS_CLASS
|
#ifdef CONFIG_LEDS_CLASS
|
||||||
static enum led_brightness logolamp_get(struct led_classdev *cdev);
|
static enum led_brightness logolamp_get(struct led_classdev *cdev);
|
||||||
@@ -816,7 +815,6 @@ static void acpi_fujitsu_notify(struct acpi_device *device, u32 event)
|
|||||||
|
|
||||||
static int acpi_fujitsu_hotkey_add(struct acpi_device *device)
|
static int acpi_fujitsu_hotkey_add(struct acpi_device *device)
|
||||||
{
|
{
|
||||||
acpi_status status;
|
|
||||||
acpi_handle handle;
|
acpi_handle handle;
|
||||||
int result = 0;
|
int result = 0;
|
||||||
int state = 0;
|
int state = 0;
|
||||||
@@ -833,17 +831,6 @@ static int acpi_fujitsu_hotkey_add(struct acpi_device *device)
|
|||||||
sprintf(acpi_device_class(device), "%s", ACPI_FUJITSU_CLASS);
|
sprintf(acpi_device_class(device), "%s", ACPI_FUJITSU_CLASS);
|
||||||
device->driver_data = fujitsu_hotkey;
|
device->driver_data = fujitsu_hotkey;
|
||||||
|
|
||||||
status = acpi_install_notify_handler(device->handle,
|
|
||||||
ACPI_DEVICE_NOTIFY,
|
|
||||||
acpi_fujitsu_hotkey_notify,
|
|
||||||
fujitsu_hotkey);
|
|
||||||
|
|
||||||
if (ACPI_FAILURE(status)) {
|
|
||||||
printk(KERN_ERR "Error installing notify handler\n");
|
|
||||||
error = -ENODEV;
|
|
||||||
goto err_stop;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* kfifo */
|
/* kfifo */
|
||||||
spin_lock_init(&fujitsu_hotkey->fifo_lock);
|
spin_lock_init(&fujitsu_hotkey->fifo_lock);
|
||||||
fujitsu_hotkey->fifo =
|
fujitsu_hotkey->fifo =
|
||||||
@@ -858,7 +845,7 @@ static int acpi_fujitsu_hotkey_add(struct acpi_device *device)
|
|||||||
fujitsu_hotkey->input = input = input_allocate_device();
|
fujitsu_hotkey->input = input = input_allocate_device();
|
||||||
if (!input) {
|
if (!input) {
|
||||||
error = -ENOMEM;
|
error = -ENOMEM;
|
||||||
goto err_uninstall_notify;
|
goto err_free_fifo;
|
||||||
}
|
}
|
||||||
|
|
||||||
snprintf(fujitsu_hotkey->phys, sizeof(fujitsu_hotkey->phys),
|
snprintf(fujitsu_hotkey->phys, sizeof(fujitsu_hotkey->phys),
|
||||||
@@ -954,9 +941,7 @@ static int acpi_fujitsu_hotkey_add(struct acpi_device *device)
|
|||||||
end:
|
end:
|
||||||
err_free_input_dev:
|
err_free_input_dev:
|
||||||
input_free_device(input);
|
input_free_device(input);
|
||||||
err_uninstall_notify:
|
err_free_fifo:
|
||||||
acpi_remove_notify_handler(device->handle, ACPI_DEVICE_NOTIFY,
|
|
||||||
acpi_fujitsu_hotkey_notify);
|
|
||||||
kfifo_free(fujitsu_hotkey->fifo);
|
kfifo_free(fujitsu_hotkey->fifo);
|
||||||
err_stop:
|
err_stop:
|
||||||
|
|
||||||
@@ -965,7 +950,6 @@ err_stop:
|
|||||||
|
|
||||||
static int acpi_fujitsu_hotkey_remove(struct acpi_device *device, int type)
|
static int acpi_fujitsu_hotkey_remove(struct acpi_device *device, int type)
|
||||||
{
|
{
|
||||||
acpi_status status;
|
|
||||||
struct fujitsu_hotkey_t *fujitsu_hotkey = NULL;
|
struct fujitsu_hotkey_t *fujitsu_hotkey = NULL;
|
||||||
|
|
||||||
if (!device || !acpi_driver_data(device))
|
if (!device || !acpi_driver_data(device))
|
||||||
@@ -973,10 +957,6 @@ static int acpi_fujitsu_hotkey_remove(struct acpi_device *device, int type)
|
|||||||
|
|
||||||
fujitsu_hotkey = acpi_driver_data(device);
|
fujitsu_hotkey = acpi_driver_data(device);
|
||||||
|
|
||||||
status = acpi_remove_notify_handler(fujitsu_hotkey->acpi_handle,
|
|
||||||
ACPI_DEVICE_NOTIFY,
|
|
||||||
acpi_fujitsu_hotkey_notify);
|
|
||||||
|
|
||||||
fujitsu_hotkey->acpi_handle = NULL;
|
fujitsu_hotkey->acpi_handle = NULL;
|
||||||
|
|
||||||
kfifo_free(fujitsu_hotkey->fifo);
|
kfifo_free(fujitsu_hotkey->fifo);
|
||||||
@@ -984,8 +964,7 @@ static int acpi_fujitsu_hotkey_remove(struct acpi_device *device, int type)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void acpi_fujitsu_hotkey_notify(acpi_handle handle, u32 event,
|
static void acpi_fujitsu_hotkey_notify(struct acpi_device *device, u32 event)
|
||||||
void *data)
|
|
||||||
{
|
{
|
||||||
struct input_dev *input;
|
struct input_dev *input;
|
||||||
int keycode, keycode_r;
|
int keycode, keycode_r;
|
||||||
@@ -1068,8 +1047,6 @@ static void acpi_fujitsu_hotkey_notify(acpi_handle handle, u32 event,
|
|||||||
input_sync(input);
|
input_sync(input);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Initialization */
|
/* Initialization */
|
||||||
@@ -1102,6 +1079,7 @@ static struct acpi_driver acpi_fujitsu_hotkey_driver = {
|
|||||||
.ops = {
|
.ops = {
|
||||||
.add = acpi_fujitsu_hotkey_add,
|
.add = acpi_fujitsu_hotkey_add,
|
||||||
.remove = acpi_fujitsu_hotkey_remove,
|
.remove = acpi_fujitsu_hotkey_remove,
|
||||||
|
.notify = acpi_fujitsu_hotkey_notify,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user