aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/platform/x86/asus_acpi.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/platform/x86/asus_acpi.c')
-rw-r--r--drivers/platform/x86/asus_acpi.c351
1 files changed, 206 insertions, 145 deletions
diff --git a/drivers/platform/x86/asus_acpi.c b/drivers/platform/x86/asus_acpi.c
index ddf5240ade8c..92fd30c9379c 100644
--- a/drivers/platform/x86/asus_acpi.c
+++ b/drivers/platform/x86/asus_acpi.c
@@ -32,9 +32,11 @@
32 32
33#include <linux/kernel.h> 33#include <linux/kernel.h>
34#include <linux/module.h> 34#include <linux/module.h>
35#include <linux/slab.h>
35#include <linux/init.h> 36#include <linux/init.h>
36#include <linux/types.h> 37#include <linux/types.h>
37#include <linux/proc_fs.h> 38#include <linux/proc_fs.h>
39#include <linux/seq_file.h>
38#include <linux/backlight.h> 40#include <linux/backlight.h>
39#include <acpi/acpi_drivers.h> 41#include <acpi/acpi_drivers.h>
40#include <acpi/acpi_bus.h> 42#include <acpi/acpi_bus.h>
@@ -466,6 +468,7 @@ MODULE_DEVICE_TABLE(acpi, asus_device_ids);
466static struct acpi_driver asus_hotk_driver = { 468static struct acpi_driver asus_hotk_driver = {
467 .name = "asus_acpi", 469 .name = "asus_acpi",
468 .class = ACPI_HOTK_CLASS, 470 .class = ACPI_HOTK_CLASS,
471 .owner = THIS_MODULE,
469 .ids = asus_device_ids, 472 .ids = asus_device_ids,
470 .flags = ACPI_DRIVER_ALL_NOTIFY_EVENTS, 473 .flags = ACPI_DRIVER_ALL_NOTIFY_EVENTS,
471 .ops = { 474 .ops = {
@@ -512,26 +515,12 @@ static int read_acpi_int(acpi_handle handle, const char *method, int *val)
512 return (status == AE_OK) && (out_obj.type == ACPI_TYPE_INTEGER); 515 return (status == AE_OK) && (out_obj.type == ACPI_TYPE_INTEGER);
513} 516}
514 517
515/* 518static int asus_info_proc_show(struct seq_file *m, void *v)
516 * We write our info in page, we begin at offset off and cannot write more
517 * than count bytes. We set eof to 1 if we handle those 2 values. We return the
518 * number of bytes written in page
519 */
520static int
521proc_read_info(char *page, char **start, off_t off, int count, int *eof,
522 void *data)
523{ 519{
524 int len = 0;
525 int temp; 520 int temp;
526 char buf[16]; /* enough for all info */
527 /*
528 * We use the easy way, we don't care of off and count,
529 * so we don't set eof to 1
530 */
531 521
532 len += sprintf(page, ACPI_HOTK_NAME " " ASUS_ACPI_VERSION "\n"); 522 seq_printf(m, ACPI_HOTK_NAME " " ASUS_ACPI_VERSION "\n");
533 len += sprintf(page + len, "Model reference : %s\n", 523 seq_printf(m, "Model reference : %s\n", hotk->methods->name);
534 hotk->methods->name);
535 /* 524 /*
536 * The SFUN method probably allows the original driver to get the list 525 * The SFUN method probably allows the original driver to get the list
537 * of features supported by a given model. For now, 0x0100 or 0x0800 526 * of features supported by a given model. For now, 0x0100 or 0x0800
@@ -539,8 +528,7 @@ proc_read_info(char *page, char **start, off_t off, int count, int *eof,
539 * The significance of others is yet to be found. 528 * The significance of others is yet to be found.
540 */ 529 */
541 if (read_acpi_int(hotk->handle, "SFUN", &temp)) 530 if (read_acpi_int(hotk->handle, "SFUN", &temp))
542 len += 531 seq_printf(m, "SFUN value : 0x%04x\n", temp);
543 sprintf(page + len, "SFUN value : 0x%04x\n", temp);
544 /* 532 /*
545 * Another value for userspace: the ASYM method returns 0x02 for 533 * Another value for userspace: the ASYM method returns 0x02 for
546 * battery low and 0x04 for battery critical, its readings tend to be 534 * battery low and 0x04 for battery critical, its readings tend to be
@@ -549,30 +537,34 @@ proc_read_info(char *page, char **start, off_t off, int count, int *eof,
549 * silently ignored. 537 * silently ignored.
550 */ 538 */
551 if (read_acpi_int(hotk->handle, "ASYM", &temp)) 539 if (read_acpi_int(hotk->handle, "ASYM", &temp))
552 len += 540 seq_printf(m, "ASYM value : 0x%04x\n", temp);
553 sprintf(page + len, "ASYM value : 0x%04x\n", temp);
554 if (asus_info) { 541 if (asus_info) {
555 snprintf(buf, 16, "%d", asus_info->length); 542 seq_printf(m, "DSDT length : %d\n", asus_info->length);
556 len += sprintf(page + len, "DSDT length : %s\n", buf); 543 seq_printf(m, "DSDT checksum : %d\n", asus_info->checksum);
557 snprintf(buf, 16, "%d", asus_info->checksum); 544 seq_printf(m, "DSDT revision : %d\n", asus_info->revision);
558 len += sprintf(page + len, "DSDT checksum : %s\n", buf); 545 seq_printf(m, "OEM id : %.*s\n", ACPI_OEM_ID_SIZE, asus_info->oem_id);
559 snprintf(buf, 16, "%d", asus_info->revision); 546 seq_printf(m, "OEM table id : %.*s\n", ACPI_OEM_TABLE_ID_SIZE, asus_info->oem_table_id);
560 len += sprintf(page + len, "DSDT revision : %s\n", buf); 547 seq_printf(m, "OEM revision : 0x%x\n", asus_info->oem_revision);
561 snprintf(buf, 7, "%s", asus_info->oem_id); 548 seq_printf(m, "ASL comp vendor id : %.*s\n", ACPI_NAME_SIZE, asus_info->asl_compiler_id);
562 len += sprintf(page + len, "OEM id : %s\n", buf); 549 seq_printf(m, "ASL comp revision : 0x%x\n", asus_info->asl_compiler_revision);
563 snprintf(buf, 9, "%s", asus_info->oem_table_id);
564 len += sprintf(page + len, "OEM table id : %s\n", buf);
565 snprintf(buf, 16, "%x", asus_info->oem_revision);
566 len += sprintf(page + len, "OEM revision : 0x%s\n", buf);
567 snprintf(buf, 5, "%s", asus_info->asl_compiler_id);
568 len += sprintf(page + len, "ASL comp vendor id : %s\n", buf);
569 snprintf(buf, 16, "%x", asus_info->asl_compiler_revision);
570 len += sprintf(page + len, "ASL comp revision : 0x%s\n", buf);
571 } 550 }
572 551
573 return len; 552 return 0;
553}
554
555static int asus_info_proc_open(struct inode *inode, struct file *file)
556{
557 return single_open(file, asus_info_proc_show, NULL);
574} 558}
575 559
560static const struct file_operations asus_info_proc_fops = {
561 .owner = THIS_MODULE,
562 .open = asus_info_proc_open,
563 .read = seq_read,
564 .llseek = seq_lseek,
565 .release = single_release,
566};
567
576/* 568/*
577 * /proc handlers 569 * /proc handlers
578 * We write our info in page, we begin at offset off and cannot write more 570 * We write our info in page, we begin at offset off and cannot write more
@@ -638,34 +630,48 @@ write_led(const char __user *buffer, unsigned long count,
638/* 630/*
639 * Proc handlers for MLED 631 * Proc handlers for MLED
640 */ 632 */
641static int 633static int mled_proc_show(struct seq_file *m, void *v)
642proc_read_mled(char *page, char **start, off_t off, int count, int *eof,
643 void *data)
644{ 634{
645 return sprintf(page, "%d\n", 635 seq_printf(m, "%d\n", read_led(hotk->methods->mled_status, MLED_ON));
646 read_led(hotk->methods->mled_status, MLED_ON)); 636 return 0;
647} 637}
648 638
649static int 639static int mled_proc_open(struct inode *inode, struct file *file)
650proc_write_mled(struct file *file, const char __user *buffer, 640{
651 unsigned long count, void *data) 641 return single_open(file, mled_proc_show, NULL);
642}
643
644static ssize_t mled_proc_write(struct file *file, const char __user *buffer,
645 size_t count, loff_t *pos)
652{ 646{
653 return write_led(buffer, count, hotk->methods->mt_mled, MLED_ON, 1); 647 return write_led(buffer, count, hotk->methods->mt_mled, MLED_ON, 1);
654} 648}
655 649
650static const struct file_operations mled_proc_fops = {
651 .owner = THIS_MODULE,
652 .open = mled_proc_open,
653 .read = seq_read,
654 .llseek = seq_lseek,
655 .release = single_release,
656 .write = mled_proc_write,
657};
658
656/* 659/*
657 * Proc handlers for LED display 660 * Proc handlers for LED display
658 */ 661 */
659static int 662static int ledd_proc_show(struct seq_file *m, void *v)
660proc_read_ledd(char *page, char **start, off_t off, int count, int *eof,
661 void *data)
662{ 663{
663 return sprintf(page, "0x%08x\n", hotk->ledd_status); 664 seq_printf(m, "0x%08x\n", hotk->ledd_status);
665 return 0;
664} 666}
665 667
666static int 668static int ledd_proc_open(struct inode *inode, struct file *file)
667proc_write_ledd(struct file *file, const char __user *buffer, 669{
668 unsigned long count, void *data) 670 return single_open(file, ledd_proc_show, NULL);
671}
672
673static ssize_t ledd_proc_write(struct file *file, const char __user *buffer,
674 size_t count, loff_t *pos)
669{ 675{
670 int rv, value; 676 int rv, value;
671 677
@@ -681,61 +687,104 @@ proc_write_ledd(struct file *file, const char __user *buffer,
681 return rv; 687 return rv;
682} 688}
683 689
690static const struct file_operations ledd_proc_fops = {
691 .owner = THIS_MODULE,
692 .open = ledd_proc_open,
693 .read = seq_read,
694 .llseek = seq_lseek,
695 .release = single_release,
696 .write = ledd_proc_write,
697};
698
684/* 699/*
685 * Proc handlers for WLED 700 * Proc handlers for WLED
686 */ 701 */
687static int 702static int wled_proc_show(struct seq_file *m, void *v)
688proc_read_wled(char *page, char **start, off_t off, int count, int *eof,
689 void *data)
690{ 703{
691 return sprintf(page, "%d\n", 704 seq_printf(m, "%d\n", read_led(hotk->methods->wled_status, WLED_ON));
692 read_led(hotk->methods->wled_status, WLED_ON)); 705 return 0;
693} 706}
694 707
695static int 708static int wled_proc_open(struct inode *inode, struct file *file)
696proc_write_wled(struct file *file, const char __user *buffer, 709{
697 unsigned long count, void *data) 710 return single_open(file, wled_proc_show, NULL);
711}
712
713static ssize_t wled_proc_write(struct file *file, const char __user *buffer,
714 size_t count, loff_t *pos)
698{ 715{
699 return write_led(buffer, count, hotk->methods->mt_wled, WLED_ON, 0); 716 return write_led(buffer, count, hotk->methods->mt_wled, WLED_ON, 0);
700} 717}
701 718
719static const struct file_operations wled_proc_fops = {
720 .owner = THIS_MODULE,
721 .open = wled_proc_open,
722 .read = seq_read,
723 .llseek = seq_lseek,
724 .release = single_release,
725 .write = wled_proc_write,
726};
727
702/* 728/*
703 * Proc handlers for Bluetooth 729 * Proc handlers for Bluetooth
704 */ 730 */
705static int 731static int bluetooth_proc_show(struct seq_file *m, void *v)
706proc_read_bluetooth(char *page, char **start, off_t off, int count, int *eof,
707 void *data)
708{ 732{
709 return sprintf(page, "%d\n", read_led(hotk->methods->bt_status, BT_ON)); 733 seq_printf(m, "%d\n", read_led(hotk->methods->bt_status, BT_ON));
734 return 0;
710} 735}
711 736
712static int 737static int bluetooth_proc_open(struct inode *inode, struct file *file)
713proc_write_bluetooth(struct file *file, const char __user *buffer, 738{
714 unsigned long count, void *data) 739 return single_open(file, bluetooth_proc_show, NULL);
740}
741
742static ssize_t bluetooth_proc_write(struct file *file,
743 const char __user *buffer, size_t count, loff_t *pos)
715{ 744{
716 /* Note: mt_bt_switch controls both internal Bluetooth adapter's 745 /* Note: mt_bt_switch controls both internal Bluetooth adapter's
717 presence and its LED */ 746 presence and its LED */
718 return write_led(buffer, count, hotk->methods->mt_bt_switch, BT_ON, 0); 747 return write_led(buffer, count, hotk->methods->mt_bt_switch, BT_ON, 0);
719} 748}
720 749
750static const struct file_operations bluetooth_proc_fops = {
751 .owner = THIS_MODULE,
752 .open = bluetooth_proc_open,
753 .read = seq_read,
754 .llseek = seq_lseek,
755 .release = single_release,
756 .write = bluetooth_proc_write,
757};
758
721/* 759/*
722 * Proc handlers for TLED 760 * Proc handlers for TLED
723 */ 761 */
724static int 762static int tled_proc_show(struct seq_file *m, void *v)
725proc_read_tled(char *page, char **start, off_t off, int count, int *eof,
726 void *data)
727{ 763{
728 return sprintf(page, "%d\n", 764 seq_printf(m, "%d\n", read_led(hotk->methods->tled_status, TLED_ON));
729 read_led(hotk->methods->tled_status, TLED_ON)); 765 return 0;
730} 766}
731 767
732static int 768static int tled_proc_open(struct inode *inode, struct file *file)
733proc_write_tled(struct file *file, const char __user *buffer, 769{
734 unsigned long count, void *data) 770 return single_open(file, tled_proc_show, NULL);
771}
772
773static ssize_t tled_proc_write(struct file *file, const char __user *buffer,
774 size_t count, loff_t *pos)
735{ 775{
736 return write_led(buffer, count, hotk->methods->mt_tled, TLED_ON, 0); 776 return write_led(buffer, count, hotk->methods->mt_tled, TLED_ON, 0);
737} 777}
738 778
779static const struct file_operations tled_proc_fops = {
780 .owner = THIS_MODULE,
781 .open = tled_proc_open,
782 .read = seq_read,
783 .llseek = seq_lseek,
784 .release = single_release,
785 .write = tled_proc_write,
786};
787
739static int get_lcd_state(void) 788static int get_lcd_state(void)
740{ 789{
741 int lcd = 0; 790 int lcd = 0;
@@ -828,16 +877,19 @@ static int set_lcd_state(int value)
828 877
829} 878}
830 879
831static int 880static int lcd_proc_show(struct seq_file *m, void *v)
832proc_read_lcd(char *page, char **start, off_t off, int count, int *eof,
833 void *data)
834{ 881{
835 return sprintf(page, "%d\n", get_lcd_state()); 882 seq_printf(m, "%d\n", get_lcd_state());
883 return 0;
836} 884}
837 885
838static int 886static int lcd_proc_open(struct inode *inode, struct file *file)
839proc_write_lcd(struct file *file, const char __user *buffer, 887{
840 unsigned long count, void *data) 888 return single_open(file, lcd_proc_show, NULL);
889}
890
891static ssize_t lcd_proc_write(struct file *file, const char __user *buffer,
892 size_t count, loff_t *pos)
841{ 893{
842 int rv, value; 894 int rv, value;
843 895
@@ -847,6 +899,15 @@ proc_write_lcd(struct file *file, const char __user *buffer,
847 return rv; 899 return rv;
848} 900}
849 901
902static const struct file_operations lcd_proc_fops = {
903 .owner = THIS_MODULE,
904 .open = lcd_proc_open,
905 .read = seq_read,
906 .llseek = seq_lseek,
907 .release = single_release,
908 .write = lcd_proc_write,
909};
910
850static int read_brightness(struct backlight_device *bd) 911static int read_brightness(struct backlight_device *bd)
851{ 912{
852 int value; 913 int value;
@@ -906,16 +967,19 @@ static int set_brightness_status(struct backlight_device *bd)
906 return set_brightness(bd->props.brightness); 967 return set_brightness(bd->props.brightness);
907} 968}
908 969
909static int 970static int brn_proc_show(struct seq_file *m, void *v)
910proc_read_brn(char *page, char **start, off_t off, int count, int *eof,
911 void *data)
912{ 971{
913 return sprintf(page, "%d\n", read_brightness(NULL)); 972 seq_printf(m, "%d\n", read_brightness(NULL));
973 return 0;
914} 974}
915 975
916static int 976static int brn_proc_open(struct inode *inode, struct file *file)
917proc_write_brn(struct file *file, const char __user *buffer, 977{
918 unsigned long count, void *data) 978 return single_open(file, brn_proc_show, NULL);
979}
980
981static ssize_t brn_proc_write(struct file *file, const char __user *buffer,
982 size_t count, loff_t *pos)
919{ 983{
920 int rv, value; 984 int rv, value;
921 985
@@ -928,6 +992,15 @@ proc_write_brn(struct file *file, const char __user *buffer,
928 return rv; 992 return rv;
929} 993}
930 994
995static const struct file_operations brn_proc_fops = {
996 .owner = THIS_MODULE,
997 .open = brn_proc_open,
998 .read = seq_read,
999 .llseek = seq_lseek,
1000 .release = single_release,
1001 .write = brn_proc_write,
1002};
1003
931static void set_display(int value) 1004static void set_display(int value)
932{ 1005{
933 /* no sanity check needed for now */ 1006 /* no sanity check needed for now */
@@ -941,9 +1014,7 @@ static void set_display(int value)
941 * Now, *this* one could be more user-friendly, but so far, no-one has 1014 * Now, *this* one could be more user-friendly, but so far, no-one has
942 * complained. The significance of bits is the same as in proc_write_disp() 1015 * complained. The significance of bits is the same as in proc_write_disp()
943 */ 1016 */
944static int 1017static int disp_proc_show(struct seq_file *m, void *v)
945proc_read_disp(char *page, char **start, off_t off, int count, int *eof,
946 void *data)
947{ 1018{
948 int value = 0; 1019 int value = 0;
949 1020
@@ -951,7 +1022,13 @@ proc_read_disp(char *page, char **start, off_t off, int count, int *eof,
951 printk(KERN_WARNING 1022 printk(KERN_WARNING
952 "Asus ACPI: Error reading display status\n"); 1023 "Asus ACPI: Error reading display status\n");
953 value &= 0x07; /* needed for some models, shouldn't hurt others */ 1024 value &= 0x07; /* needed for some models, shouldn't hurt others */
954 return sprintf(page, "%d\n", value); 1025 seq_printf(m, "%d\n", value);
1026 return 0;
1027}
1028
1029static int disp_proc_open(struct inode *inode, struct file *file)
1030{
1031 return single_open(file, disp_proc_show, NULL);
955} 1032}
956 1033
957/* 1034/*
@@ -960,9 +1037,8 @@ proc_read_disp(char *page, char **start, off_t off, int count, int *eof,
960 * (bitwise) of these will suffice. I never actually tested 3 displays hooked 1037 * (bitwise) of these will suffice. I never actually tested 3 displays hooked
961 * up simultaneously, so be warned. See the acpi4asus README for more info. 1038 * up simultaneously, so be warned. See the acpi4asus README for more info.
962 */ 1039 */
963static int 1040static ssize_t disp_proc_write(struct file *file, const char __user *buffer,
964proc_write_disp(struct file *file, const char __user *buffer, 1041 size_t count, loff_t *pos)
965 unsigned long count, void *data)
966{ 1042{
967 int rv, value; 1043 int rv, value;
968 1044
@@ -972,25 +1048,27 @@ proc_write_disp(struct file *file, const char __user *buffer,
972 return rv; 1048 return rv;
973} 1049}
974 1050
975typedef int (proc_readfunc) (char *page, char **start, off_t off, int count, 1051static const struct file_operations disp_proc_fops = {
976 int *eof, void *data); 1052 .owner = THIS_MODULE,
977typedef int (proc_writefunc) (struct file *file, const char __user *buffer, 1053 .open = disp_proc_open,
978 unsigned long count, void *data); 1054 .read = seq_read,
1055 .llseek = seq_lseek,
1056 .release = single_release,
1057 .write = disp_proc_write,
1058};
979 1059
980static int 1060static int
981asus_proc_add(char *name, proc_writefunc *writefunc, 1061asus_proc_add(char *name, const struct file_operations *proc_fops, mode_t mode,
982 proc_readfunc *readfunc, mode_t mode,
983 struct acpi_device *device) 1062 struct acpi_device *device)
984{ 1063{
985 struct proc_dir_entry *proc = 1064 struct proc_dir_entry *proc;
986 create_proc_entry(name, mode, acpi_device_dir(device)); 1065
1066 proc = proc_create_data(name, mode, acpi_device_dir(device),
1067 proc_fops, acpi_driver_data(device));
987 if (!proc) { 1068 if (!proc) {
988 printk(KERN_WARNING " Unable to create %s fs entry\n", name); 1069 printk(KERN_WARNING " Unable to create %s fs entry\n", name);
989 return -1; 1070 return -1;
990 } 1071 }
991 proc->write_proc = writefunc;
992 proc->read_proc = readfunc;
993 proc->data = acpi_driver_data(device);
994 proc->uid = asus_uid; 1072 proc->uid = asus_uid;
995 proc->gid = asus_gid; 1073 proc->gid = asus_gid;
996 return 0; 1074 return 0;
@@ -1019,10 +1097,9 @@ static int asus_hotk_add_fs(struct acpi_device *device)
1019 if (!acpi_device_dir(device)) 1097 if (!acpi_device_dir(device))
1020 return -ENODEV; 1098 return -ENODEV;
1021 1099
1022 proc = create_proc_entry(PROC_INFO, mode, acpi_device_dir(device)); 1100 proc = proc_create(PROC_INFO, mode, acpi_device_dir(device),
1101 &asus_info_proc_fops);
1023 if (proc) { 1102 if (proc) {
1024 proc->read_proc = proc_read_info;
1025 proc->data = acpi_driver_data(device);
1026 proc->uid = asus_uid; 1103 proc->uid = asus_uid;
1027 proc->gid = asus_gid; 1104 proc->gid = asus_gid;
1028 } else { 1105 } else {
@@ -1031,28 +1108,23 @@ static int asus_hotk_add_fs(struct acpi_device *device)
1031 } 1108 }
1032 1109
1033 if (hotk->methods->mt_wled) { 1110 if (hotk->methods->mt_wled) {
1034 asus_proc_add(PROC_WLED, &proc_write_wled, &proc_read_wled, 1111 asus_proc_add(PROC_WLED, &wled_proc_fops, mode, device);
1035 mode, device);
1036 } 1112 }
1037 1113
1038 if (hotk->methods->mt_ledd) { 1114 if (hotk->methods->mt_ledd) {
1039 asus_proc_add(PROC_LEDD, &proc_write_ledd, &proc_read_ledd, 1115 asus_proc_add(PROC_LEDD, &ledd_proc_fops, mode, device);
1040 mode, device);
1041 } 1116 }
1042 1117
1043 if (hotk->methods->mt_mled) { 1118 if (hotk->methods->mt_mled) {
1044 asus_proc_add(PROC_MLED, &proc_write_mled, &proc_read_mled, 1119 asus_proc_add(PROC_MLED, &mled_proc_fops, mode, device);
1045 mode, device);
1046 } 1120 }
1047 1121
1048 if (hotk->methods->mt_tled) { 1122 if (hotk->methods->mt_tled) {
1049 asus_proc_add(PROC_TLED, &proc_write_tled, &proc_read_tled, 1123 asus_proc_add(PROC_TLED, &tled_proc_fops, mode, device);
1050 mode, device);
1051 } 1124 }
1052 1125
1053 if (hotk->methods->mt_bt_switch) { 1126 if (hotk->methods->mt_bt_switch) {
1054 asus_proc_add(PROC_BT, &proc_write_bluetooth, 1127 asus_proc_add(PROC_BT, &bluetooth_proc_fops, mode, device);
1055 &proc_read_bluetooth, mode, device);
1056 } 1128 }
1057 1129
1058 /* 1130 /*
@@ -1060,19 +1132,16 @@ static int asus_hotk_add_fs(struct acpi_device *device)
1060 * accessible from the keyboard 1132 * accessible from the keyboard
1061 */ 1133 */
1062 if (hotk->methods->mt_lcd_switch && hotk->methods->lcd_status) { 1134 if (hotk->methods->mt_lcd_switch && hotk->methods->lcd_status) {
1063 asus_proc_add(PROC_LCD, &proc_write_lcd, &proc_read_lcd, mode, 1135 asus_proc_add(PROC_LCD, &lcd_proc_fops, mode, device);
1064 device);
1065 } 1136 }
1066 1137
1067 if ((hotk->methods->brightness_up && hotk->methods->brightness_down) || 1138 if ((hotk->methods->brightness_up && hotk->methods->brightness_down) ||
1068 (hotk->methods->brightness_get && hotk->methods->brightness_set)) { 1139 (hotk->methods->brightness_get && hotk->methods->brightness_set)) {
1069 asus_proc_add(PROC_BRN, &proc_write_brn, &proc_read_brn, mode, 1140 asus_proc_add(PROC_BRN, &brn_proc_fops, mode, device);
1070 device);
1071 } 1141 }
1072 1142
1073 if (hotk->methods->display_set) { 1143 if (hotk->methods->display_set) {
1074 asus_proc_add(PROC_DISP, &proc_write_disp, &proc_read_disp, 1144 asus_proc_add(PROC_DISP, &disp_proc_fops, mode, device);
1075 mode, device);
1076 } 1145 }
1077 1146
1078 return 0; 1147 return 0;
@@ -1157,9 +1226,8 @@ static int asus_model_match(char *model)
1157 else if (strncmp(model, "M2N", 3) == 0 || 1226 else if (strncmp(model, "M2N", 3) == 0 ||
1158 strncmp(model, "M3N", 3) == 0 || 1227 strncmp(model, "M3N", 3) == 0 ||
1159 strncmp(model, "M5N", 3) == 0 || 1228 strncmp(model, "M5N", 3) == 0 ||
1160 strncmp(model, "M6N", 3) == 0 ||
1161 strncmp(model, "S1N", 3) == 0 || 1229 strncmp(model, "S1N", 3) == 0 ||
1162 strncmp(model, "S5N", 3) == 0 || strncmp(model, "W1N", 3) == 0) 1230 strncmp(model, "S5N", 3) == 0)
1163 return xxN; 1231 return xxN;
1164 else if (strncmp(model, "M1", 2) == 0) 1232 else if (strncmp(model, "M1", 2) == 0)
1165 return M1A; 1233 return M1A;
@@ -1334,9 +1402,6 @@ static int asus_hotk_add(struct acpi_device *device)
1334 acpi_status status = AE_OK; 1402 acpi_status status = AE_OK;
1335 int result; 1403 int result;
1336 1404
1337 if (!device)
1338 return -EINVAL;
1339
1340 printk(KERN_NOTICE "Asus Laptop ACPI Extras version %s\n", 1405 printk(KERN_NOTICE "Asus Laptop ACPI Extras version %s\n",
1341 ASUS_ACPI_VERSION); 1406 ASUS_ACPI_VERSION);
1342 1407
@@ -1392,9 +1457,6 @@ end:
1392 1457
1393static int asus_hotk_remove(struct acpi_device *device, int type) 1458static int asus_hotk_remove(struct acpi_device *device, int type)
1394{ 1459{
1395 if (!device || !acpi_driver_data(device))
1396 return -EINVAL;
1397
1398 asus_hotk_remove_fs(device); 1460 asus_hotk_remove_fs(device);
1399 1461
1400 kfree(hotk); 1462 kfree(hotk);
@@ -1420,23 +1482,20 @@ static void asus_acpi_exit(void)
1420 1482
1421static int __init asus_acpi_init(void) 1483static int __init asus_acpi_init(void)
1422{ 1484{
1485 struct backlight_properties props;
1423 int result; 1486 int result;
1424 1487
1425 if (acpi_disabled) 1488 result = acpi_bus_register_driver(&asus_hotk_driver);
1426 return -ENODEV; 1489 if (result < 0)
1490 return result;
1427 1491
1428 asus_proc_dir = proc_mkdir(PROC_ASUS, acpi_root_dir); 1492 asus_proc_dir = proc_mkdir(PROC_ASUS, acpi_root_dir);
1429 if (!asus_proc_dir) { 1493 if (!asus_proc_dir) {
1430 printk(KERN_ERR "Asus ACPI: Unable to create /proc entry\n"); 1494 printk(KERN_ERR "Asus ACPI: Unable to create /proc entry\n");
1495 acpi_bus_unregister_driver(&asus_hotk_driver);
1431 return -ENODEV; 1496 return -ENODEV;
1432 } 1497 }
1433 1498
1434 result = acpi_bus_register_driver(&asus_hotk_driver);
1435 if (result < 0) {
1436 remove_proc_entry(PROC_ASUS, acpi_root_dir);
1437 return result;
1438 }
1439
1440 /* 1499 /*
1441 * This is a bit of a kludge. We only want this module loaded 1500 * This is a bit of a kludge. We only want this module loaded
1442 * for ASUS systems, but there's currently no way to probe the 1501 * for ASUS systems, but there's currently no way to probe the
@@ -1450,15 +1509,17 @@ static int __init asus_acpi_init(void)
1450 return -ENODEV; 1509 return -ENODEV;
1451 } 1510 }
1452 1511
1512 memset(&props, 0, sizeof(struct backlight_properties));
1513 props.max_brightness = 15;
1453 asus_backlight_device = backlight_device_register("asus", NULL, NULL, 1514 asus_backlight_device = backlight_device_register("asus", NULL, NULL,
1454 &asus_backlight_data); 1515 &asus_backlight_data,
1516 &props);
1455 if (IS_ERR(asus_backlight_device)) { 1517 if (IS_ERR(asus_backlight_device)) {
1456 printk(KERN_ERR "Could not register asus backlight device\n"); 1518 printk(KERN_ERR "Could not register asus backlight device\n");
1457 asus_backlight_device = NULL; 1519 asus_backlight_device = NULL;
1458 asus_acpi_exit(); 1520 asus_acpi_exit();
1459 return -ENODEV; 1521 return -ENODEV;
1460 } 1522 }
1461 asus_backlight_device->props.max_brightness = 15;
1462 1523
1463 return 0; 1524 return 0;
1464} 1525}