X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=drivers%2Facpi%2Fbutton.c;h=4b6d9f0096a10cb8cdf1409f8558cff7674b1e9b;hb=9464c7cf61b9433057924c36e6e02f303a00e768;hp=5ef885e82c78a94b7352307307ac4b5e35e0b08f;hpb=41689045f6a3cbe0550e1d34e9cc20d2e8c432ba;p=linux-2.6.git diff --git a/drivers/acpi/button.c b/drivers/acpi/button.c index 5ef885e82..4b6d9f009 100644 --- a/drivers/acpi/button.c +++ b/drivers/acpi/button.c @@ -82,19 +82,20 @@ static struct acpi_driver acpi_button_driver = { }; struct acpi_button { + acpi_handle handle; struct acpi_device *device; /* Fixed button kludge */ u8 type; unsigned long pushed; }; -static const struct file_operations acpi_button_info_fops = { +static struct file_operations acpi_button_info_fops = { .open = acpi_button_info_open_fs, .read = seq_read, .llseek = seq_lseek, .release = single_release, }; -static const struct file_operations acpi_button_state_fops = { +static struct file_operations acpi_button_state_fops = { .open = acpi_button_state_open_fs, .read = seq_read, .llseek = seq_lseek, @@ -111,14 +112,15 @@ static int acpi_button_info_seq_show(struct seq_file *seq, void *offset) { struct acpi_button *button = (struct acpi_button *)seq->private; + ACPI_FUNCTION_TRACE("acpi_button_info_seq_show"); if (!button || !button->device) - return 0; + return_VALUE(0); seq_printf(seq, "type: %s\n", acpi_device_name(button->device)); - return 0; + return_VALUE(0); } static int acpi_button_info_open_fs(struct inode *inode, struct file *file) @@ -132,11 +134,12 @@ static int acpi_button_state_seq_show(struct seq_file *seq, void *offset) acpi_status status; unsigned long state; + ACPI_FUNCTION_TRACE("acpi_button_state_seq_show"); if (!button || !button->device) - return 0; + return_VALUE(0); - status = acpi_evaluate_integer(button->device->handle, "_LID", NULL, &state); + status = acpi_evaluate_integer(button->handle, "_LID", NULL, &state); if (ACPI_FAILURE(status)) { seq_printf(seq, "state: unsupported\n"); } else { @@ -144,7 +147,7 @@ static int acpi_button_state_seq_show(struct seq_file *seq, void *offset) (state ? "open" : "closed")); } - return 0; + return_VALUE(0); } static int acpi_button_state_open_fs(struct inode *inode, struct file *file) @@ -161,9 +164,10 @@ static int acpi_button_add_fs(struct acpi_device *device) struct proc_dir_entry *entry = NULL; struct acpi_button *button = NULL; + ACPI_FUNCTION_TRACE("acpi_button_add_fs"); if (!device || !acpi_driver_data(device)) - return -EINVAL; + return_VALUE(-EINVAL); button = acpi_driver_data(device); @@ -191,19 +195,21 @@ static int acpi_button_add_fs(struct acpi_device *device) } if (!entry) - return -ENODEV; + return_VALUE(-ENODEV); entry->owner = THIS_MODULE; acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device), entry); if (!acpi_device_dir(device)) - return -ENODEV; + return_VALUE(-ENODEV); acpi_device_dir(device)->owner = THIS_MODULE; /* 'info' [R] */ entry = create_proc_entry(ACPI_BUTTON_FILE_INFO, S_IRUGO, acpi_device_dir(device)); if (!entry) - return -ENODEV; + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Unable to create '%s' fs entry\n", + ACPI_BUTTON_FILE_INFO)); else { entry->proc_fops = &acpi_button_info_fops; entry->data = acpi_driver_data(device); @@ -215,7 +221,9 @@ static int acpi_button_add_fs(struct acpi_device *device) entry = create_proc_entry(ACPI_BUTTON_FILE_STATE, S_IRUGO, acpi_device_dir(device)); if (!entry) - return -ENODEV; + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Unable to create '%s' fs entry\n", + ACPI_BUTTON_FILE_INFO)); else { entry->proc_fops = &acpi_button_state_fops; entry->data = acpi_driver_data(device); @@ -223,13 +231,14 @@ static int acpi_button_add_fs(struct acpi_device *device) } } - return 0; + return_VALUE(0); } static int acpi_button_remove_fs(struct acpi_device *device) { struct acpi_button *button = NULL; + ACPI_FUNCTION_TRACE("acpi_button_remove_fs"); button = acpi_driver_data(device); if (acpi_device_dir(device)) { @@ -244,7 +253,7 @@ static int acpi_button_remove_fs(struct acpi_device *device) acpi_device_dir(device) = NULL; } - return 0; + return_VALUE(0); } /* -------------------------------------------------------------------------- @@ -255,9 +264,10 @@ static void acpi_button_notify(acpi_handle handle, u32 event, void *data) { struct acpi_button *button = (struct acpi_button *)data; + ACPI_FUNCTION_TRACE("acpi_button_notify"); if (!button || !button->device) - return; + return_VOID; switch (event) { case ACPI_BUTTON_NOTIFY_STATUS: @@ -270,20 +280,21 @@ static void acpi_button_notify(acpi_handle handle, u32 event, void *data) break; } - return; + return_VOID; } static acpi_status acpi_button_notify_fixed(void *data) { struct acpi_button *button = (struct acpi_button *)data; + ACPI_FUNCTION_TRACE("acpi_button_notify_fixed"); if (!button) - return AE_BAD_PARAMETER; + return_ACPI_STATUS(AE_BAD_PARAMETER); - acpi_button_notify(button->device->handle, ACPI_BUTTON_NOTIFY_STATUS, button); + acpi_button_notify(button->handle, ACPI_BUTTON_NOTIFY_STATUS, button); - return AE_OK; + return_ACPI_STATUS(AE_OK); } static int acpi_button_add(struct acpi_device *device) @@ -292,16 +303,18 @@ static int acpi_button_add(struct acpi_device *device) acpi_status status = AE_OK; struct acpi_button *button = NULL; + ACPI_FUNCTION_TRACE("acpi_button_add"); if (!device) - return -EINVAL; + return_VALUE(-EINVAL); button = kmalloc(sizeof(struct acpi_button), GFP_KERNEL); if (!button) - return -ENOMEM; + return_VALUE(-ENOMEM); memset(button, 0, sizeof(struct acpi_button)); button->device = device; + button->handle = device->handle; acpi_driver_data(device) = button; /* @@ -336,8 +349,8 @@ static int acpi_button_add(struct acpi_device *device) sprintf(acpi_device_class(device), "%s/%s", ACPI_BUTTON_CLASS, ACPI_BUTTON_SUBCLASS_LID); } else { - printk(KERN_ERR PREFIX "Unsupported hid [%s]\n", - acpi_device_hid(device)); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Unsupported hid [%s]\n", + acpi_device_hid(device))); result = -ENODEV; goto end; } @@ -360,7 +373,7 @@ static int acpi_button_add(struct acpi_device *device) button); break; default: - status = acpi_install_notify_handler(device->handle, + status = acpi_install_notify_handler(button->handle, ACPI_DEVICE_NOTIFY, acpi_button_notify, button); @@ -368,6 +381,8 @@ static int acpi_button_add(struct acpi_device *device) } if (ACPI_FAILURE(status)) { + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Error installing notify handler\n")); result = -ENODEV; goto end; } @@ -391,7 +406,7 @@ static int acpi_button_add(struct acpi_device *device) kfree(button); } - return result; + return_VALUE(result); } static int acpi_button_remove(struct acpi_device *device, int type) @@ -399,9 +414,10 @@ static int acpi_button_remove(struct acpi_device *device, int type) acpi_status status = 0; struct acpi_button *button = NULL; + ACPI_FUNCTION_TRACE("acpi_button_remove"); if (!device || !acpi_driver_data(device)) - return -EINVAL; + return_VALUE(-EINVAL); button = acpi_driver_data(device); @@ -418,39 +434,45 @@ static int acpi_button_remove(struct acpi_device *device, int type) acpi_button_notify_fixed); break; default: - status = acpi_remove_notify_handler(device->handle, + status = acpi_remove_notify_handler(button->handle, ACPI_DEVICE_NOTIFY, acpi_button_notify); break; } + if (ACPI_FAILURE(status)) + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Error removing notify handler\n")); + acpi_button_remove_fs(device); kfree(button); - return 0; + return_VALUE(0); } static int __init acpi_button_init(void) { int result = 0; + ACPI_FUNCTION_TRACE("acpi_button_init"); acpi_button_dir = proc_mkdir(ACPI_BUTTON_CLASS, acpi_root_dir); if (!acpi_button_dir) - return -ENODEV; + return_VALUE(-ENODEV); acpi_button_dir->owner = THIS_MODULE; result = acpi_bus_register_driver(&acpi_button_driver); if (result < 0) { remove_proc_entry(ACPI_BUTTON_CLASS, acpi_root_dir); - return -ENODEV; + return_VALUE(-ENODEV); } - return 0; + return_VALUE(0); } static void __exit acpi_button_exit(void) { + ACPI_FUNCTION_TRACE("acpi_button_exit"); acpi_bus_unregister_driver(&acpi_button_driver); @@ -462,7 +484,7 @@ static void __exit acpi_button_exit(void) remove_proc_entry(ACPI_BUTTON_SUBCLASS_LID, acpi_button_dir); remove_proc_entry(ACPI_BUTTON_CLASS, acpi_root_dir); - return; + return_VOID; } module_init(acpi_button_init);