aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/hotkey.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/acpi/hotkey.c')
-rw-r--r--drivers/acpi/hotkey.c94
1 files changed, 36 insertions, 58 deletions
diff --git a/drivers/acpi/hotkey.c b/drivers/acpi/hotkey.c
index 393dbbca4e8..fd81a0f5222 100644
--- a/drivers/acpi/hotkey.c
+++ b/drivers/acpi/hotkey.c
@@ -231,11 +231,10 @@ struct list_head hotkey_entries; /* head of the list of hotkey_list */
231 231
232static int hotkey_info_seq_show(struct seq_file *seq, void *offset) 232static int hotkey_info_seq_show(struct seq_file *seq, void *offset)
233{ 233{
234 ACPI_FUNCTION_TRACE("hotkey_info_seq_show");
235 234
236 seq_printf(seq, "Hotkey generic driver ver: %s\n", HOTKEY_ACPI_VERSION); 235 seq_printf(seq, "Hotkey generic driver ver: %s\n", HOTKEY_ACPI_VERSION);
237 236
238 return_VALUE(0); 237 return 0;
239} 238}
240 239
241static int hotkey_info_open_fs(struct inode *inode, struct file *file) 240static int hotkey_info_open_fs(struct inode *inode, struct file *file)
@@ -266,7 +265,6 @@ static int hotkey_polling_seq_show(struct seq_file *seq, void *offset)
266 (struct acpi_polling_hotkey *)seq->private; 265 (struct acpi_polling_hotkey *)seq->private;
267 char *buf; 266 char *buf;
268 267
269 ACPI_FUNCTION_TRACE("hotkey_polling_seq_show");
270 268
271 if (poll_hotkey->poll_result) { 269 if (poll_hotkey->poll_result) {
272 buf = format_result(poll_hotkey->poll_result); 270 buf = format_result(poll_hotkey->poll_result);
@@ -274,7 +272,7 @@ static int hotkey_polling_seq_show(struct seq_file *seq, void *offset)
274 seq_printf(seq, "%s", buf); 272 seq_printf(seq, "%s", buf);
275 kfree(buf); 273 kfree(buf);
276 } 274 }
277 return_VALUE(0); 275 return 0;
278} 276}
279 277
280static int hotkey_polling_open_fs(struct inode *inode, struct file *file) 278static int hotkey_polling_open_fs(struct inode *inode, struct file *file)
@@ -293,7 +291,6 @@ static int hotkey_get_internal_event(int event, struct acpi_hotkey_list *list)
293 struct list_head *entries; 291 struct list_head *entries;
294 int val = -1; 292 int val = -1;
295 293
296 ACPI_FUNCTION_TRACE("hotkey_get_internal_event");
297 294
298 list_for_each(entries, list->entries) { 295 list_for_each(entries, list->entries) {
299 union acpi_hotkey *key = 296 union acpi_hotkey *key =
@@ -305,7 +302,7 @@ static int hotkey_get_internal_event(int event, struct acpi_hotkey_list *list)
305 } 302 }
306 } 303 }
307 304
308 return_VALUE(val); 305 return val;
309} 306}
310 307
311static void 308static void
@@ -314,15 +311,14 @@ acpi_hotkey_notify_handler(acpi_handle handle, u32 event, void *data)
314 struct acpi_device *device = NULL; 311 struct acpi_device *device = NULL;
315 u32 internal_event; 312 u32 internal_event;
316 313
317 ACPI_FUNCTION_TRACE("acpi_hotkey_notify_handler");
318 314
319 if (acpi_bus_get_device(handle, &device)) 315 if (acpi_bus_get_device(handle, &device))
320 return_VOID; 316 return;
321 317
322 internal_event = hotkey_get_internal_event(event, &global_hotkey_list); 318 internal_event = hotkey_get_internal_event(event, &global_hotkey_list);
323 acpi_bus_generate_event(device, internal_event, 0); 319 acpi_bus_generate_event(device, internal_event, 0);
324 320
325 return_VOID; 321 return;
326} 322}
327 323
328/* Need to invent automatically hotkey add method */ 324/* Need to invent automatically hotkey add method */
@@ -346,7 +342,6 @@ static int create_polling_proc(union acpi_hotkey *device)
346 char proc_name[80]; 342 char proc_name[80];
347 mode_t mode; 343 mode_t mode;
348 344
349 ACPI_FUNCTION_TRACE("create_polling_proc");
350 mode = S_IFREG | S_IRUGO | S_IWUGO; 345 mode = S_IFREG | S_IRUGO | S_IWUGO;
351 346
352 sprintf(proc_name, "%d", device->link.hotkey_standard_num); 347 sprintf(proc_name, "%d", device->link.hotkey_standard_num);
@@ -356,7 +351,7 @@ static int create_polling_proc(union acpi_hotkey *device)
356 proc = create_proc_entry(proc_name, mode, hotkey_proc_dir); 351 proc = create_proc_entry(proc_name, mode, hotkey_proc_dir);
357 352
358 if (!proc) { 353 if (!proc) {
359 return_VALUE(-ENODEV); 354 return -ENODEV;
360 } else { 355 } else {
361 proc->proc_fops = &hotkey_polling_fops; 356 proc->proc_fops = &hotkey_polling_fops;
362 proc->owner = THIS_MODULE; 357 proc->owner = THIS_MODULE;
@@ -365,7 +360,7 @@ static int create_polling_proc(union acpi_hotkey *device)
365 proc->gid = 0; 360 proc->gid = 0;
366 device->poll_hotkey.proc = proc; 361 device->poll_hotkey.proc = proc;
367 } 362 }
368 return_VALUE(0); 363 return 0;
369} 364}
370 365
371static int hotkey_add(union acpi_hotkey *device) 366static int hotkey_add(union acpi_hotkey *device)
@@ -373,7 +368,6 @@ static int hotkey_add(union acpi_hotkey *device)
373 int status = 0; 368 int status = 0;
374 struct acpi_device *dev = NULL; 369 struct acpi_device *dev = NULL;
375 370
376 ACPI_FUNCTION_TRACE("hotkey_add");
377 371
378 if (device->link.hotkey_type == ACPI_HOTKEY_EVENT) { 372 if (device->link.hotkey_type == ACPI_HOTKEY_EVENT) {
379 acpi_bus_get_device(device->event_hotkey.bus_handle, &dev); 373 acpi_bus_get_device(device->event_hotkey.bus_handle, &dev);
@@ -388,14 +382,13 @@ static int hotkey_add(union acpi_hotkey *device)
388 382
389 list_add_tail(&device->link.entries, global_hotkey_list.entries); 383 list_add_tail(&device->link.entries, global_hotkey_list.entries);
390 384
391 return_VALUE(status); 385 return status;
392} 386}
393 387
394static int hotkey_remove(union acpi_hotkey *device) 388static int hotkey_remove(union acpi_hotkey *device)
395{ 389{
396 struct list_head *entries, *next; 390 struct list_head *entries, *next;
397 391
398 ACPI_FUNCTION_TRACE("hotkey_remove");
399 392
400 list_for_each_safe(entries, next, global_hotkey_list.entries) { 393 list_for_each_safe(entries, next, global_hotkey_list.entries) {
401 union acpi_hotkey *key = 394 union acpi_hotkey *key =
@@ -409,14 +402,13 @@ static int hotkey_remove(union acpi_hotkey *device)
409 } 402 }
410 } 403 }
411 kfree(device); 404 kfree(device);
412 return_VALUE(0); 405 return 0;
413} 406}
414 407
415static int hotkey_update(union acpi_hotkey *key) 408static int hotkey_update(union acpi_hotkey *key)
416{ 409{
417 struct list_head *entries; 410 struct list_head *entries;
418 411
419 ACPI_FUNCTION_TRACE("hotkey_update");
420 412
421 list_for_each(entries, global_hotkey_list.entries) { 413 list_for_each(entries, global_hotkey_list.entries) {
422 union acpi_hotkey *tmp = 414 union acpi_hotkey *tmp =
@@ -458,19 +450,18 @@ static int hotkey_update(union acpi_hotkey *key)
458 */ 450 */
459 kfree(key); 451 kfree(key);
460 } 452 }
461 return_VALUE(0); 453 return 0;
462 break; 454 break;
463 } 455 }
464 } 456 }
465 457
466 return_VALUE(-ENODEV); 458 return -ENODEV;
467} 459}
468 460
469static void free_hotkey_device(union acpi_hotkey *key) 461static void free_hotkey_device(union acpi_hotkey *key)
470{ 462{
471 struct acpi_device *dev; 463 struct acpi_device *dev;
472 464
473 ACPI_FUNCTION_TRACE("free_hotkey_device");
474 465
475 if (key->link.hotkey_type == ACPI_HOTKEY_EVENT) { 466 if (key->link.hotkey_type == ACPI_HOTKEY_EVENT) {
476 acpi_bus_get_device(key->event_hotkey.bus_handle, &dev); 467 acpi_bus_get_device(key->event_hotkey.bus_handle, &dev);
@@ -490,7 +481,7 @@ static void free_hotkey_device(union acpi_hotkey *key)
490 free_poll_hotkey_buffer(key); 481 free_poll_hotkey_buffer(key);
491 } 482 }
492 kfree(key); 483 kfree(key);
493 return_VOID; 484 return;
494} 485}
495 486
496static void free_hotkey_buffer(union acpi_hotkey *key) 487static void free_hotkey_buffer(union acpi_hotkey *key)
@@ -511,7 +502,6 @@ init_hotkey_device(union acpi_hotkey *key, char *bus_str, char *action_str,
511 acpi_handle tmp_handle; 502 acpi_handle tmp_handle;
512 acpi_status status = AE_OK; 503 acpi_status status = AE_OK;
513 504
514 ACPI_FUNCTION_TRACE("init_hotkey_device");
515 505
516 if (std_num < 0 || IS_POLL(std_num) || !key) 506 if (std_num < 0 || IS_POLL(std_num) || !key)
517 goto do_fail; 507 goto do_fail;
@@ -538,9 +528,9 @@ init_hotkey_device(union acpi_hotkey *key, char *bus_str, char *action_str,
538 method, &tmp_handle); 528 method, &tmp_handle);
539 if (ACPI_FAILURE(status)) 529 if (ACPI_FAILURE(status))
540 goto do_fail; 530 goto do_fail;
541 return_VALUE(AE_OK); 531 return AE_OK;
542 do_fail: 532 do_fail:
543 return_VALUE(-ENODEV); 533 return -ENODEV;
544} 534}
545 535
546static int 536static int
@@ -552,7 +542,6 @@ init_poll_hotkey_device(union acpi_hotkey *key,
552 acpi_status status = AE_OK; 542 acpi_status status = AE_OK;
553 acpi_handle tmp_handle; 543 acpi_handle tmp_handle;
554 544
555 ACPI_FUNCTION_TRACE("init_poll_hotkey_device");
556 545
557 if (std_num < 0 || IS_EVENT(std_num) || !key) 546 if (std_num < 0 || IS_EVENT(std_num) || !key)
558 goto do_fail; 547 goto do_fail;
@@ -587,22 +576,20 @@ init_poll_hotkey_device(union acpi_hotkey *key,
587 (union acpi_object *)kmalloc(sizeof(union acpi_object), GFP_KERNEL); 576 (union acpi_object *)kmalloc(sizeof(union acpi_object), GFP_KERNEL);
588 if (!key->poll_hotkey.poll_result) 577 if (!key->poll_hotkey.poll_result)
589 goto do_fail; 578 goto do_fail;
590 return_VALUE(AE_OK); 579 return AE_OK;
591 do_fail: 580 do_fail:
592 return_VALUE(-ENODEV); 581 return -ENODEV;
593} 582}
594 583
595static int hotkey_open_config(struct inode *inode, struct file *file) 584static int hotkey_open_config(struct inode *inode, struct file *file)
596{ 585{
597 ACPI_FUNCTION_TRACE("hotkey_open_config"); 586 return (single_open
598 return_VALUE(single_open
599 (file, hotkey_config_seq_show, PDE(inode)->data)); 587 (file, hotkey_config_seq_show, PDE(inode)->data));
600} 588}
601 589
602static int hotkey_poll_open_config(struct inode *inode, struct file *file) 590static int hotkey_poll_open_config(struct inode *inode, struct file *file)
603{ 591{
604 ACPI_FUNCTION_TRACE("hotkey_poll_open_config"); 592 return (single_open
605 return_VALUE(single_open
606 (file, hotkey_poll_config_seq_show, PDE(inode)->data)); 593 (file, hotkey_poll_config_seq_show, PDE(inode)->data));
607} 594}
608 595
@@ -615,7 +602,6 @@ static int hotkey_config_seq_show(struct seq_file *seq, void *offset)
615 struct acpi_buffer bus = { ACPI_PATHNAME_MAX, bus_name }; 602 struct acpi_buffer bus = { ACPI_PATHNAME_MAX, bus_name };
616 struct acpi_buffer act = { ACPI_PATHNAME_MAX, action_name }; 603 struct acpi_buffer act = { ACPI_PATHNAME_MAX, action_name };
617 604
618 ACPI_FUNCTION_TRACE(("hotkey_config_seq_show"));
619 605
620 list_for_each(entries, hotkey_list->entries) { 606 list_for_each(entries, hotkey_list->entries) {
621 union acpi_hotkey *key = 607 union acpi_hotkey *key =
@@ -633,7 +619,7 @@ static int hotkey_config_seq_show(struct seq_file *seq, void *offset)
633 } 619 }
634 } 620 }
635 seq_puts(seq, "\n"); 621 seq_puts(seq, "\n");
636 return_VALUE(0); 622 return 0;
637} 623}
638 624
639static int hotkey_poll_config_seq_show(struct seq_file *seq, void *offset) 625static int hotkey_poll_config_seq_show(struct seq_file *seq, void *offset)
@@ -645,7 +631,6 @@ static int hotkey_poll_config_seq_show(struct seq_file *seq, void *offset)
645 struct acpi_buffer bus = { ACPI_PATHNAME_MAX, bus_name }; 631 struct acpi_buffer bus = { ACPI_PATHNAME_MAX, bus_name };
646 struct acpi_buffer act = { ACPI_PATHNAME_MAX, action_name }; 632 struct acpi_buffer act = { ACPI_PATHNAME_MAX, action_name };
647 633
648 ACPI_FUNCTION_TRACE(("hotkey_config_seq_show"));
649 634
650 list_for_each(entries, hotkey_list->entries) { 635 list_for_each(entries, hotkey_list->entries) {
651 union acpi_hotkey *key = 636 union acpi_hotkey *key =
@@ -663,7 +648,7 @@ static int hotkey_poll_config_seq_show(struct seq_file *seq, void *offset)
663 } 648 }
664 } 649 }
665 seq_puts(seq, "\n"); 650 seq_puts(seq, "\n");
666 return_VALUE(0); 651 return 0;
667} 652}
668 653
669static int 654static int
@@ -675,7 +660,6 @@ get_parms(char *config_record,
675 char **method, int *internal_event_num, int *external_event_num) 660 char **method, int *internal_event_num, int *external_event_num)
676{ 661{
677 char *tmp, *tmp1, count; 662 char *tmp, *tmp1, count;
678 ACPI_FUNCTION_TRACE(("get_parms"));
679 663
680 sscanf(config_record, "%d", cmd); 664 sscanf(config_record, "%d", cmd);
681 665
@@ -741,9 +725,9 @@ get_parms(char *config_record,
741 0) 725 0)
742 goto do_fail; 726 goto do_fail;
743 727
744 return_VALUE(6); 728 return 6;
745 do_fail: 729 do_fail:
746 return_VALUE(-1); 730 return -1;
747} 731}
748 732
749/* count is length for one input record */ 733/* count is length for one input record */
@@ -760,16 +744,15 @@ static ssize_t hotkey_write_config(struct file *file,
760 int ret = 0; 744 int ret = 0;
761 union acpi_hotkey *key = NULL; 745 union acpi_hotkey *key = NULL;
762 746
763 ACPI_FUNCTION_TRACE(("hotkey_write_config"));
764 747
765 config_record = (char *)kmalloc(count + 1, GFP_KERNEL); 748 config_record = (char *)kmalloc(count + 1, GFP_KERNEL);
766 if (!config_record) 749 if (!config_record)
767 return_VALUE(-ENOMEM); 750 return -ENOMEM;
768 751
769 if (copy_from_user(config_record, buffer, count)) { 752 if (copy_from_user(config_record, buffer, count)) {
770 kfree(config_record); 753 kfree(config_record);
771 printk(KERN_ERR PREFIX "Invalid data\n"); 754 printk(KERN_ERR PREFIX "Invalid data\n");
772 return_VALUE(-EINVAL); 755 return -EINVAL;
773 } 756 }
774 config_record[count] = 0; 757 config_record[count] = 0;
775 758
@@ -790,7 +773,7 @@ static ssize_t hotkey_write_config(struct file *file,
790 kfree(action_handle); 773 kfree(action_handle);
791 kfree(method); 774 kfree(method);
792 printk(KERN_ERR PREFIX "Invalid data format ret=%d\n", ret); 775 printk(KERN_ERR PREFIX "Invalid data format ret=%d\n", ret);
793 return_VALUE(-EINVAL); 776 return -EINVAL;
794 } 777 }
795 778
796 key = kmalloc(sizeof(union acpi_hotkey), GFP_KERNEL); 779 key = kmalloc(sizeof(union acpi_hotkey), GFP_KERNEL);
@@ -825,7 +808,7 @@ static ssize_t hotkey_write_config(struct file *file,
825 free_poll_hotkey_buffer(key); 808 free_poll_hotkey_buffer(key);
826 kfree(key); 809 kfree(key);
827 printk(KERN_ERR PREFIX "Invalid hotkey\n"); 810 printk(KERN_ERR PREFIX "Invalid hotkey\n");
828 return_VALUE(-EINVAL); 811 return -EINVAL;
829 } 812 }
830 813
831 cont_cmd: 814 cont_cmd:
@@ -851,7 +834,7 @@ static ssize_t hotkey_write_config(struct file *file,
851 goto fail_out; 834 goto fail_out;
852 break; 835 break;
853 } 836 }
854 return_VALUE(count); 837 return count;
855 fail_out: 838 fail_out:
856 if (IS_EVENT(internal_event_num)) 839 if (IS_EVENT(internal_event_num))
857 free_hotkey_buffer(key); 840 free_hotkey_buffer(key);
@@ -859,7 +842,7 @@ static ssize_t hotkey_write_config(struct file *file,
859 free_poll_hotkey_buffer(key); 842 free_poll_hotkey_buffer(key);
860 kfree(key); 843 kfree(key);
861 printk(KERN_ERR PREFIX "invalid key\n"); 844 printk(KERN_ERR PREFIX "invalid key\n");
862 return_VALUE(-EINVAL); 845 return -EINVAL;
863} 846}
864 847
865/* 848/*
@@ -876,7 +859,6 @@ static int write_acpi_int(acpi_handle handle, const char *method, int val,
876 union acpi_object in_obj; /* the only param we use */ 859 union acpi_object in_obj; /* the only param we use */
877 acpi_status status; 860 acpi_status status;
878 861
879 ACPI_FUNCTION_TRACE("write_acpi_int");
880 params.count = 1; 862 params.count = 1;
881 params.pointer = &in_obj; 863 params.pointer = &in_obj;
882 in_obj.type = ACPI_TYPE_INTEGER; 864 in_obj.type = ACPI_TYPE_INTEGER;
@@ -884,7 +866,7 @@ static int write_acpi_int(acpi_handle handle, const char *method, int val,
884 866
885 status = acpi_evaluate_object(handle, (char *)method, &params, output); 867 status = acpi_evaluate_object(handle, (char *)method, &params, output);
886 868
887 return_VALUE(status == AE_OK); 869 return (status == AE_OK);
888} 870}
889 871
890static int read_acpi_int(acpi_handle handle, const char *method, 872static int read_acpi_int(acpi_handle handle, const char *method,
@@ -894,7 +876,6 @@ static int read_acpi_int(acpi_handle handle, const char *method,
894 union acpi_object out_obj; 876 union acpi_object out_obj;
895 acpi_status status; 877 acpi_status status;
896 878
897 ACPI_FUNCTION_TRACE("read_acpi_int");
898 output.length = sizeof(out_obj); 879 output.length = sizeof(out_obj);
899 output.pointer = &out_obj; 880 output.pointer = &out_obj;
900 881
@@ -904,7 +885,7 @@ static int read_acpi_int(acpi_handle handle, const char *method,
904 val->type = out_obj.type; 885 val->type = out_obj.type;
905 } else 886 } else
906 printk(KERN_ERR PREFIX "null val pointer\n"); 887 printk(KERN_ERR PREFIX "null val pointer\n");
907 return_VALUE((status == AE_OK) 888 return ((status == AE_OK)
908 && (out_obj.type == ACPI_TYPE_INTEGER)); 889 && (out_obj.type == ACPI_TYPE_INTEGER));
909} 890}
910 891
@@ -941,24 +922,23 @@ static ssize_t hotkey_execute_aml_method(struct file *file,
941 int event, method_type, type, value; 922 int event, method_type, type, value;
942 union acpi_hotkey *key; 923 union acpi_hotkey *key;
943 924
944 ACPI_FUNCTION_TRACE("hotkey_execte_aml_method");
945 925
946 arg = (char *)kmalloc(count + 1, GFP_KERNEL); 926 arg = (char *)kmalloc(count + 1, GFP_KERNEL);
947 if (!arg) 927 if (!arg)
948 return_VALUE(-ENOMEM); 928 return -ENOMEM;
949 arg[count] = 0; 929 arg[count] = 0;
950 930
951 if (copy_from_user(arg, buffer, count)) { 931 if (copy_from_user(arg, buffer, count)) {
952 kfree(arg); 932 kfree(arg);
953 printk(KERN_ERR PREFIX "Invalid argument 2\n"); 933 printk(KERN_ERR PREFIX "Invalid argument 2\n");
954 return_VALUE(-EINVAL); 934 return -EINVAL;
955 } 935 }
956 936
957 if (sscanf(arg, "%d:%d:%d:%d", &event, &method_type, &type, &value) != 937 if (sscanf(arg, "%d:%d:%d:%d", &event, &method_type, &type, &value) !=
958 4) { 938 4) {
959 kfree(arg); 939 kfree(arg);
960 printk(KERN_ERR PREFIX "Invalid argument 3\n"); 940 printk(KERN_ERR PREFIX "Invalid argument 3\n");
961 return_VALUE(-EINVAL); 941 return -EINVAL;
962 } 942 }
963 kfree(arg); 943 kfree(arg);
964 if (type == ACPI_TYPE_INTEGER) { 944 if (type == ACPI_TYPE_INTEGER) {
@@ -984,11 +964,11 @@ static ssize_t hotkey_execute_aml_method(struct file *file,
984 } 964 }
985 } else { 965 } else {
986 printk(KERN_WARNING "Not supported\n"); 966 printk(KERN_WARNING "Not supported\n");
987 return_VALUE(-EINVAL); 967 return -EINVAL;
988 } 968 }
989 return_VALUE(count); 969 return count;
990 do_fail: 970 do_fail:
991 return_VALUE(-EINVAL); 971 return -EINVAL;
992 972
993} 973}
994 974
@@ -997,7 +977,6 @@ static int __init hotkey_init(void)
997 int result; 977 int result;
998 mode_t mode = S_IFREG | S_IRUGO | S_IWUGO; 978 mode_t mode = S_IFREG | S_IRUGO | S_IWUGO;
999 979
1000 ACPI_FUNCTION_TRACE("hotkey_init");
1001 980
1002 if (acpi_disabled) 981 if (acpi_disabled)
1003 return -ENODEV; 982 return -ENODEV;
@@ -1084,7 +1063,6 @@ static void __exit hotkey_exit(void)
1084{ 1063{
1085 struct list_head *entries, *next; 1064 struct list_head *entries, *next;
1086 1065
1087 ACPI_FUNCTION_TRACE("hotkey_exit");
1088 1066
1089 list_for_each_safe(entries, next, global_hotkey_list.entries) { 1067 list_for_each_safe(entries, next, global_hotkey_list.entries) {
1090 union acpi_hotkey *key = 1068 union acpi_hotkey *key =