aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/misc/wistron_btns.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/input/misc/wistron_btns.c')
-rw-r--r--drivers/input/misc/wistron_btns.c256
1 files changed, 83 insertions, 173 deletions
diff --git a/drivers/input/misc/wistron_btns.c b/drivers/input/misc/wistron_btns.c
index a932179c4c9e..38da6ab04384 100644
--- a/drivers/input/misc/wistron_btns.c
+++ b/drivers/input/misc/wistron_btns.c
@@ -21,6 +21,7 @@
21#include <linux/dmi.h> 21#include <linux/dmi.h>
22#include <linux/init.h> 22#include <linux/init.h>
23#include <linux/input-polldev.h> 23#include <linux/input-polldev.h>
24#include <linux/input/sparse-keymap.h>
24#include <linux/interrupt.h> 25#include <linux/interrupt.h>
25#include <linux/jiffies.h> 26#include <linux/jiffies.h>
26#include <linux/kernel.h> 27#include <linux/kernel.h>
@@ -224,19 +225,8 @@ static void bios_set_state(u8 subsys, int enable)
224 225
225/* Hardware database */ 226/* Hardware database */
226 227
227struct key_entry { 228#define KE_WIFI (KE_LAST + 1)
228 char type; /* See KE_* below */ 229#define KE_BLUETOOTH (KE_LAST + 2)
229 u8 code;
230 union {
231 u16 keycode; /* For KE_KEY */
232 struct { /* For KE_SW */
233 u8 code;
234 u8 value;
235 } sw;
236 };
237};
238
239enum { KE_END, KE_KEY, KE_SW, KE_WIFI, KE_BLUETOOTH };
240 230
241#define FE_MAIL_LED 0x01 231#define FE_MAIL_LED 0x01
242#define FE_WIFI_LED 0x02 232#define FE_WIFI_LED 0x02
@@ -644,10 +634,10 @@ static struct key_entry keymap_prestigio[] __initdata = {
644 * a list of buttons and their key codes (reported when loading this module 634 * a list of buttons and their key codes (reported when loading this module
645 * with force=1) and the output of dmidecode to $MODULE_AUTHOR. 635 * with force=1) and the output of dmidecode to $MODULE_AUTHOR.
646 */ 636 */
647static struct dmi_system_id dmi_ids[] __initdata = { 637static const struct dmi_system_id __initconst dmi_ids[] = {
648 { 638 {
639 /* Fujitsu-Siemens Amilo Pro V2000 */
649 .callback = dmi_matched, 640 .callback = dmi_matched,
650 .ident = "Fujitsu-Siemens Amilo Pro V2000",
651 .matches = { 641 .matches = {
652 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"), 642 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"),
653 DMI_MATCH(DMI_PRODUCT_NAME, "AMILO Pro V2000"), 643 DMI_MATCH(DMI_PRODUCT_NAME, "AMILO Pro V2000"),
@@ -655,8 +645,8 @@ static struct dmi_system_id dmi_ids[] __initdata = {
655 .driver_data = keymap_fs_amilo_pro_v2000 645 .driver_data = keymap_fs_amilo_pro_v2000
656 }, 646 },
657 { 647 {
648 /* Fujitsu-Siemens Amilo Pro Edition V3505 */
658 .callback = dmi_matched, 649 .callback = dmi_matched,
659 .ident = "Fujitsu-Siemens Amilo Pro Edition V3505",
660 .matches = { 650 .matches = {
661 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"), 651 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"),
662 DMI_MATCH(DMI_PRODUCT_NAME, "AMILO Pro Edition V3505"), 652 DMI_MATCH(DMI_PRODUCT_NAME, "AMILO Pro Edition V3505"),
@@ -664,8 +654,8 @@ static struct dmi_system_id dmi_ids[] __initdata = {
664 .driver_data = keymap_fs_amilo_pro_v3505 654 .driver_data = keymap_fs_amilo_pro_v3505
665 }, 655 },
666 { 656 {
657 /* Fujitsu-Siemens Amilo M7400 */
667 .callback = dmi_matched, 658 .callback = dmi_matched,
668 .ident = "Fujitsu-Siemens Amilo M7400",
669 .matches = { 659 .matches = {
670 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"), 660 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"),
671 DMI_MATCH(DMI_PRODUCT_NAME, "AMILO M "), 661 DMI_MATCH(DMI_PRODUCT_NAME, "AMILO M "),
@@ -673,8 +663,8 @@ static struct dmi_system_id dmi_ids[] __initdata = {
673 .driver_data = keymap_fs_amilo_pro_v2000 663 .driver_data = keymap_fs_amilo_pro_v2000
674 }, 664 },
675 { 665 {
666 /* Maxdata Pro 7000 DX */
676 .callback = dmi_matched, 667 .callback = dmi_matched,
677 .ident = "Maxdata Pro 7000 DX",
678 .matches = { 668 .matches = {
679 DMI_MATCH(DMI_SYS_VENDOR, "MAXDATA"), 669 DMI_MATCH(DMI_SYS_VENDOR, "MAXDATA"),
680 DMI_MATCH(DMI_PRODUCT_NAME, "Pro 7000"), 670 DMI_MATCH(DMI_PRODUCT_NAME, "Pro 7000"),
@@ -682,8 +672,8 @@ static struct dmi_system_id dmi_ids[] __initdata = {
682 .driver_data = keymap_fs_amilo_pro_v2000 672 .driver_data = keymap_fs_amilo_pro_v2000
683 }, 673 },
684 { 674 {
675 /* Fujitsu N3510 */
685 .callback = dmi_matched, 676 .callback = dmi_matched,
686 .ident = "Fujitsu N3510",
687 .matches = { 677 .matches = {
688 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"), 678 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"),
689 DMI_MATCH(DMI_PRODUCT_NAME, "N3510"), 679 DMI_MATCH(DMI_PRODUCT_NAME, "N3510"),
@@ -691,8 +681,8 @@ static struct dmi_system_id dmi_ids[] __initdata = {
691 .driver_data = keymap_fujitsu_n3510 681 .driver_data = keymap_fujitsu_n3510
692 }, 682 },
693 { 683 {
684 /* Acer Aspire 1500 */
694 .callback = dmi_matched, 685 .callback = dmi_matched,
695 .ident = "Acer Aspire 1500",
696 .matches = { 686 .matches = {
697 DMI_MATCH(DMI_SYS_VENDOR, "Acer"), 687 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
698 DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 1500"), 688 DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 1500"),
@@ -700,8 +690,8 @@ static struct dmi_system_id dmi_ids[] __initdata = {
700 .driver_data = keymap_acer_aspire_1500 690 .driver_data = keymap_acer_aspire_1500
701 }, 691 },
702 { 692 {
693 /* Acer Aspire 1600 */
703 .callback = dmi_matched, 694 .callback = dmi_matched,
704 .ident = "Acer Aspire 1600",
705 .matches = { 695 .matches = {
706 DMI_MATCH(DMI_SYS_VENDOR, "Acer"), 696 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
707 DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 1600"), 697 DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 1600"),
@@ -709,8 +699,8 @@ static struct dmi_system_id dmi_ids[] __initdata = {
709 .driver_data = keymap_acer_aspire_1600 699 .driver_data = keymap_acer_aspire_1600
710 }, 700 },
711 { 701 {
702 /* Acer Aspire 3020 */
712 .callback = dmi_matched, 703 .callback = dmi_matched,
713 .ident = "Acer Aspire 3020",
714 .matches = { 704 .matches = {
715 DMI_MATCH(DMI_SYS_VENDOR, "Acer"), 705 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
716 DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 3020"), 706 DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 3020"),
@@ -718,8 +708,8 @@ static struct dmi_system_id dmi_ids[] __initdata = {
718 .driver_data = keymap_acer_aspire_5020 708 .driver_data = keymap_acer_aspire_5020
719 }, 709 },
720 { 710 {
711 /* Acer Aspire 5020 */
721 .callback = dmi_matched, 712 .callback = dmi_matched,
722 .ident = "Acer Aspire 5020",
723 .matches = { 713 .matches = {
724 DMI_MATCH(DMI_SYS_VENDOR, "Acer"), 714 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
725 DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5020"), 715 DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5020"),
@@ -727,8 +717,8 @@ static struct dmi_system_id dmi_ids[] __initdata = {
727 .driver_data = keymap_acer_aspire_5020 717 .driver_data = keymap_acer_aspire_5020
728 }, 718 },
729 { 719 {
720 /* Acer TravelMate 2100 */
730 .callback = dmi_matched, 721 .callback = dmi_matched,
731 .ident = "Acer TravelMate 2100",
732 .matches = { 722 .matches = {
733 DMI_MATCH(DMI_SYS_VENDOR, "Acer"), 723 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
734 DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 2100"), 724 DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 2100"),
@@ -736,8 +726,8 @@ static struct dmi_system_id dmi_ids[] __initdata = {
736 .driver_data = keymap_acer_aspire_5020 726 .driver_data = keymap_acer_aspire_5020
737 }, 727 },
738 { 728 {
729 /* Acer TravelMate 2410 */
739 .callback = dmi_matched, 730 .callback = dmi_matched,
740 .ident = "Acer TravelMate 2410",
741 .matches = { 731 .matches = {
742 DMI_MATCH(DMI_SYS_VENDOR, "Acer"), 732 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
743 DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 2410"), 733 DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 2410"),
@@ -745,8 +735,8 @@ static struct dmi_system_id dmi_ids[] __initdata = {
745 .driver_data = keymap_acer_travelmate_2410 735 .driver_data = keymap_acer_travelmate_2410
746 }, 736 },
747 { 737 {
738 /* Acer TravelMate C300 */
748 .callback = dmi_matched, 739 .callback = dmi_matched,
749 .ident = "Acer TravelMate C300",
750 .matches = { 740 .matches = {
751 DMI_MATCH(DMI_SYS_VENDOR, "Acer"), 741 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
752 DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate C300"), 742 DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate C300"),
@@ -754,8 +744,8 @@ static struct dmi_system_id dmi_ids[] __initdata = {
754 .driver_data = keymap_acer_travelmate_300 744 .driver_data = keymap_acer_travelmate_300
755 }, 745 },
756 { 746 {
747 /* Acer TravelMate C100 */
757 .callback = dmi_matched, 748 .callback = dmi_matched,
758 .ident = "Acer TravelMate C100",
759 .matches = { 749 .matches = {
760 DMI_MATCH(DMI_SYS_VENDOR, "Acer"), 750 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
761 DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate C100"), 751 DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate C100"),
@@ -763,8 +753,8 @@ static struct dmi_system_id dmi_ids[] __initdata = {
763 .driver_data = keymap_acer_travelmate_300 753 .driver_data = keymap_acer_travelmate_300
764 }, 754 },
765 { 755 {
756 /* Acer TravelMate C110 */
766 .callback = dmi_matched, 757 .callback = dmi_matched,
767 .ident = "Acer TravelMate C110",
768 .matches = { 758 .matches = {
769 DMI_MATCH(DMI_SYS_VENDOR, "Acer"), 759 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
770 DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate C110"), 760 DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate C110"),
@@ -772,8 +762,8 @@ static struct dmi_system_id dmi_ids[] __initdata = {
772 .driver_data = keymap_acer_travelmate_110 762 .driver_data = keymap_acer_travelmate_110
773 }, 763 },
774 { 764 {
765 /* Acer TravelMate 380 */
775 .callback = dmi_matched, 766 .callback = dmi_matched,
776 .ident = "Acer TravelMate 380",
777 .matches = { 767 .matches = {
778 DMI_MATCH(DMI_SYS_VENDOR, "Acer"), 768 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
779 DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 380"), 769 DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 380"),
@@ -781,8 +771,8 @@ static struct dmi_system_id dmi_ids[] __initdata = {
781 .driver_data = keymap_acer_travelmate_380 771 .driver_data = keymap_acer_travelmate_380
782 }, 772 },
783 { 773 {
774 /* Acer TravelMate 370 */
784 .callback = dmi_matched, 775 .callback = dmi_matched,
785 .ident = "Acer TravelMate 370",
786 .matches = { 776 .matches = {
787 DMI_MATCH(DMI_SYS_VENDOR, "Acer"), 777 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
788 DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 370"), 778 DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 370"),
@@ -790,8 +780,8 @@ static struct dmi_system_id dmi_ids[] __initdata = {
790 .driver_data = keymap_acer_travelmate_380 /* keyboard minus 1 key */ 780 .driver_data = keymap_acer_travelmate_380 /* keyboard minus 1 key */
791 }, 781 },
792 { 782 {
783 /* Acer TravelMate 220 */
793 .callback = dmi_matched, 784 .callback = dmi_matched,
794 .ident = "Acer TravelMate 220",
795 .matches = { 785 .matches = {
796 DMI_MATCH(DMI_SYS_VENDOR, "Acer"), 786 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
797 DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 220"), 787 DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 220"),
@@ -799,8 +789,8 @@ static struct dmi_system_id dmi_ids[] __initdata = {
799 .driver_data = keymap_acer_travelmate_220 789 .driver_data = keymap_acer_travelmate_220
800 }, 790 },
801 { 791 {
792 /* Acer TravelMate 260 */
802 .callback = dmi_matched, 793 .callback = dmi_matched,
803 .ident = "Acer TravelMate 260",
804 .matches = { 794 .matches = {
805 DMI_MATCH(DMI_SYS_VENDOR, "Acer"), 795 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
806 DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 260"), 796 DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 260"),
@@ -808,8 +798,8 @@ static struct dmi_system_id dmi_ids[] __initdata = {
808 .driver_data = keymap_acer_travelmate_220 798 .driver_data = keymap_acer_travelmate_220
809 }, 799 },
810 { 800 {
801 /* Acer TravelMate 230 */
811 .callback = dmi_matched, 802 .callback = dmi_matched,
812 .ident = "Acer TravelMate 230",
813 .matches = { 803 .matches = {
814 DMI_MATCH(DMI_SYS_VENDOR, "Acer"), 804 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
815 DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 230"), 805 DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 230"),
@@ -818,8 +808,8 @@ static struct dmi_system_id dmi_ids[] __initdata = {
818 .driver_data = keymap_acer_travelmate_230 808 .driver_data = keymap_acer_travelmate_230
819 }, 809 },
820 { 810 {
811 /* Acer TravelMate 280 */
821 .callback = dmi_matched, 812 .callback = dmi_matched,
822 .ident = "Acer TravelMate 280",
823 .matches = { 813 .matches = {
824 DMI_MATCH(DMI_SYS_VENDOR, "Acer"), 814 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
825 DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 280"), 815 DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 280"),
@@ -827,8 +817,8 @@ static struct dmi_system_id dmi_ids[] __initdata = {
827 .driver_data = keymap_acer_travelmate_230 817 .driver_data = keymap_acer_travelmate_230
828 }, 818 },
829 { 819 {
820 /* Acer TravelMate 240 */
830 .callback = dmi_matched, 821 .callback = dmi_matched,
831 .ident = "Acer TravelMate 240",
832 .matches = { 822 .matches = {
833 DMI_MATCH(DMI_SYS_VENDOR, "Acer"), 823 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
834 DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 240"), 824 DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 240"),
@@ -836,8 +826,8 @@ static struct dmi_system_id dmi_ids[] __initdata = {
836 .driver_data = keymap_acer_travelmate_240 826 .driver_data = keymap_acer_travelmate_240
837 }, 827 },
838 { 828 {
829 /* Acer TravelMate 250 */
839 .callback = dmi_matched, 830 .callback = dmi_matched,
840 .ident = "Acer TravelMate 250",
841 .matches = { 831 .matches = {
842 DMI_MATCH(DMI_SYS_VENDOR, "Acer"), 832 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
843 DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 250"), 833 DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 250"),
@@ -845,8 +835,8 @@ static struct dmi_system_id dmi_ids[] __initdata = {
845 .driver_data = keymap_acer_travelmate_240 835 .driver_data = keymap_acer_travelmate_240
846 }, 836 },
847 { 837 {
838 /* Acer TravelMate 2424NWXCi */
848 .callback = dmi_matched, 839 .callback = dmi_matched,
849 .ident = "Acer TravelMate 2424NWXCi",
850 .matches = { 840 .matches = {
851 DMI_MATCH(DMI_SYS_VENDOR, "Acer"), 841 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
852 DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 2420"), 842 DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 2420"),
@@ -854,8 +844,8 @@ static struct dmi_system_id dmi_ids[] __initdata = {
854 .driver_data = keymap_acer_travelmate_240 844 .driver_data = keymap_acer_travelmate_240
855 }, 845 },
856 { 846 {
847 /* Acer TravelMate 350 */
857 .callback = dmi_matched, 848 .callback = dmi_matched,
858 .ident = "Acer TravelMate 350",
859 .matches = { 849 .matches = {
860 DMI_MATCH(DMI_SYS_VENDOR, "Acer"), 850 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
861 DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 350"), 851 DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 350"),
@@ -863,8 +853,8 @@ static struct dmi_system_id dmi_ids[] __initdata = {
863 .driver_data = keymap_acer_travelmate_350 853 .driver_data = keymap_acer_travelmate_350
864 }, 854 },
865 { 855 {
856 /* Acer TravelMate 360 */
866 .callback = dmi_matched, 857 .callback = dmi_matched,
867 .ident = "Acer TravelMate 360",
868 .matches = { 858 .matches = {
869 DMI_MATCH(DMI_SYS_VENDOR, "Acer"), 859 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
870 DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 360"), 860 DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 360"),
@@ -872,8 +862,8 @@ static struct dmi_system_id dmi_ids[] __initdata = {
872 .driver_data = keymap_acer_travelmate_360 862 .driver_data = keymap_acer_travelmate_360
873 }, 863 },
874 { 864 {
865 /* Acer TravelMate 610 */
875 .callback = dmi_matched, 866 .callback = dmi_matched,
876 .ident = "Acer TravelMate 610",
877 .matches = { 867 .matches = {
878 DMI_MATCH(DMI_SYS_VENDOR, "ACER"), 868 DMI_MATCH(DMI_SYS_VENDOR, "ACER"),
879 DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 610"), 869 DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 610"),
@@ -881,8 +871,8 @@ static struct dmi_system_id dmi_ids[] __initdata = {
881 .driver_data = keymap_acer_travelmate_610 871 .driver_data = keymap_acer_travelmate_610
882 }, 872 },
883 { 873 {
874 /* Acer TravelMate 620 */
884 .callback = dmi_matched, 875 .callback = dmi_matched,
885 .ident = "Acer TravelMate 620",
886 .matches = { 876 .matches = {
887 DMI_MATCH(DMI_SYS_VENDOR, "Acer"), 877 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
888 DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 620"), 878 DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 620"),
@@ -890,8 +880,8 @@ static struct dmi_system_id dmi_ids[] __initdata = {
890 .driver_data = keymap_acer_travelmate_630 880 .driver_data = keymap_acer_travelmate_630
891 }, 881 },
892 { 882 {
883 /* Acer TravelMate 630 */
893 .callback = dmi_matched, 884 .callback = dmi_matched,
894 .ident = "Acer TravelMate 630",
895 .matches = { 885 .matches = {
896 DMI_MATCH(DMI_SYS_VENDOR, "Acer"), 886 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
897 DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 630"), 887 DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 630"),
@@ -899,8 +889,8 @@ static struct dmi_system_id dmi_ids[] __initdata = {
899 .driver_data = keymap_acer_travelmate_630 889 .driver_data = keymap_acer_travelmate_630
900 }, 890 },
901 { 891 {
892 /* AOpen 1559AS */
902 .callback = dmi_matched, 893 .callback = dmi_matched,
903 .ident = "AOpen 1559AS",
904 .matches = { 894 .matches = {
905 DMI_MATCH(DMI_PRODUCT_NAME, "E2U"), 895 DMI_MATCH(DMI_PRODUCT_NAME, "E2U"),
906 DMI_MATCH(DMI_BOARD_NAME, "E2U"), 896 DMI_MATCH(DMI_BOARD_NAME, "E2U"),
@@ -908,8 +898,8 @@ static struct dmi_system_id dmi_ids[] __initdata = {
908 .driver_data = keymap_aopen_1559as 898 .driver_data = keymap_aopen_1559as
909 }, 899 },
910 { 900 {
901 /* Medion MD 9783 */
911 .callback = dmi_matched, 902 .callback = dmi_matched,
912 .ident = "Medion MD 9783",
913 .matches = { 903 .matches = {
914 DMI_MATCH(DMI_SYS_VENDOR, "MEDIONNB"), 904 DMI_MATCH(DMI_SYS_VENDOR, "MEDIONNB"),
915 DMI_MATCH(DMI_PRODUCT_NAME, "MD 9783"), 905 DMI_MATCH(DMI_PRODUCT_NAME, "MD 9783"),
@@ -917,8 +907,8 @@ static struct dmi_system_id dmi_ids[] __initdata = {
917 .driver_data = keymap_wistron_ms2111 907 .driver_data = keymap_wistron_ms2111
918 }, 908 },
919 { 909 {
910 /* Medion MD 40100 */
920 .callback = dmi_matched, 911 .callback = dmi_matched,
921 .ident = "Medion MD 40100",
922 .matches = { 912 .matches = {
923 DMI_MATCH(DMI_SYS_VENDOR, "MEDIONNB"), 913 DMI_MATCH(DMI_SYS_VENDOR, "MEDIONNB"),
924 DMI_MATCH(DMI_PRODUCT_NAME, "WID2000"), 914 DMI_MATCH(DMI_PRODUCT_NAME, "WID2000"),
@@ -926,8 +916,8 @@ static struct dmi_system_id dmi_ids[] __initdata = {
926 .driver_data = keymap_wistron_md40100 916 .driver_data = keymap_wistron_md40100
927 }, 917 },
928 { 918 {
919 /* Medion MD 2900 */
929 .callback = dmi_matched, 920 .callback = dmi_matched,
930 .ident = "Medion MD 2900",
931 .matches = { 921 .matches = {
932 DMI_MATCH(DMI_SYS_VENDOR, "MEDIONNB"), 922 DMI_MATCH(DMI_SYS_VENDOR, "MEDIONNB"),
933 DMI_MATCH(DMI_PRODUCT_NAME, "WIM 2000"), 923 DMI_MATCH(DMI_PRODUCT_NAME, "WIM 2000"),
@@ -935,8 +925,8 @@ static struct dmi_system_id dmi_ids[] __initdata = {
935 .driver_data = keymap_wistron_md2900 925 .driver_data = keymap_wistron_md2900
936 }, 926 },
937 { 927 {
928 /* Medion MD 42200 */
938 .callback = dmi_matched, 929 .callback = dmi_matched,
939 .ident = "Medion MD 42200",
940 .matches = { 930 .matches = {
941 DMI_MATCH(DMI_SYS_VENDOR, "Medion"), 931 DMI_MATCH(DMI_SYS_VENDOR, "Medion"),
942 DMI_MATCH(DMI_PRODUCT_NAME, "WIM 2030"), 932 DMI_MATCH(DMI_PRODUCT_NAME, "WIM 2030"),
@@ -944,8 +934,8 @@ static struct dmi_system_id dmi_ids[] __initdata = {
944 .driver_data = keymap_fs_amilo_pro_v2000 934 .driver_data = keymap_fs_amilo_pro_v2000
945 }, 935 },
946 { 936 {
937 /* Medion MD 96500 */
947 .callback = dmi_matched, 938 .callback = dmi_matched,
948 .ident = "Medion MD 96500",
949 .matches = { 939 .matches = {
950 DMI_MATCH(DMI_SYS_VENDOR, "MEDIONPC"), 940 DMI_MATCH(DMI_SYS_VENDOR, "MEDIONPC"),
951 DMI_MATCH(DMI_PRODUCT_NAME, "WIM 2040"), 941 DMI_MATCH(DMI_PRODUCT_NAME, "WIM 2040"),
@@ -953,8 +943,8 @@ static struct dmi_system_id dmi_ids[] __initdata = {
953 .driver_data = keymap_wistron_md96500 943 .driver_data = keymap_wistron_md96500
954 }, 944 },
955 { 945 {
946 /* Medion MD 95400 */
956 .callback = dmi_matched, 947 .callback = dmi_matched,
957 .ident = "Medion MD 95400",
958 .matches = { 948 .matches = {
959 DMI_MATCH(DMI_SYS_VENDOR, "MEDIONPC"), 949 DMI_MATCH(DMI_SYS_VENDOR, "MEDIONPC"),
960 DMI_MATCH(DMI_PRODUCT_NAME, "WIM 2050"), 950 DMI_MATCH(DMI_PRODUCT_NAME, "WIM 2050"),
@@ -962,8 +952,8 @@ static struct dmi_system_id dmi_ids[] __initdata = {
962 .driver_data = keymap_wistron_md96500 952 .driver_data = keymap_wistron_md96500
963 }, 953 },
964 { 954 {
955 /* Fujitsu Siemens Amilo D7820 */
965 .callback = dmi_matched, 956 .callback = dmi_matched,
966 .ident = "Fujitsu Siemens Amilo D7820",
967 .matches = { 957 .matches = {
968 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"), /* not sure */ 958 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"), /* not sure */
969 DMI_MATCH(DMI_PRODUCT_NAME, "Amilo D"), 959 DMI_MATCH(DMI_PRODUCT_NAME, "Amilo D"),
@@ -971,8 +961,8 @@ static struct dmi_system_id dmi_ids[] __initdata = {
971 .driver_data = keymap_fs_amilo_d88x0 961 .driver_data = keymap_fs_amilo_d88x0
972 }, 962 },
973 { 963 {
964 /* Fujitsu Siemens Amilo D88x0 */
974 .callback = dmi_matched, 965 .callback = dmi_matched,
975 .ident = "Fujitsu Siemens Amilo D88x0",
976 .matches = { 966 .matches = {
977 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"), 967 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"),
978 DMI_MATCH(DMI_PRODUCT_NAME, "AMILO D"), 968 DMI_MATCH(DMI_PRODUCT_NAME, "AMILO D"),
@@ -1037,21 +1027,6 @@ static unsigned long jiffies_last_press;
1037static bool wifi_enabled; 1027static bool wifi_enabled;
1038static bool bluetooth_enabled; 1028static bool bluetooth_enabled;
1039 1029
1040static void report_key(struct input_dev *dev, unsigned int keycode)
1041{
1042 input_report_key(dev, keycode, 1);
1043 input_sync(dev);
1044 input_report_key(dev, keycode, 0);
1045 input_sync(dev);
1046}
1047
1048static void report_switch(struct input_dev *dev, unsigned int code, int value)
1049{
1050 input_report_switch(dev, code, value);
1051 input_sync(dev);
1052}
1053
1054
1055 /* led management */ 1030 /* led management */
1056static void wistron_mail_led_set(struct led_classdev *led_cdev, 1031static void wistron_mail_led_set(struct led_classdev *led_cdev,
1057 enum led_brightness value) 1032 enum led_brightness value)
@@ -1128,43 +1103,13 @@ static inline void wistron_led_resume(void)
1128 led_classdev_resume(&wistron_wifi_led); 1103 led_classdev_resume(&wistron_wifi_led);
1129} 1104}
1130 1105
1131static struct key_entry *wistron_get_entry_by_scancode(int code)
1132{
1133 struct key_entry *key;
1134
1135 for (key = keymap; key->type != KE_END; key++)
1136 if (code == key->code)
1137 return key;
1138
1139 return NULL;
1140}
1141
1142static struct key_entry *wistron_get_entry_by_keycode(int keycode)
1143{
1144 struct key_entry *key;
1145
1146 for (key = keymap; key->type != KE_END; key++)
1147 if (key->type == KE_KEY && keycode == key->keycode)
1148 return key;
1149
1150 return NULL;
1151}
1152
1153static void handle_key(u8 code) 1106static void handle_key(u8 code)
1154{ 1107{
1155 const struct key_entry *key = wistron_get_entry_by_scancode(code); 1108 const struct key_entry *key =
1109 sparse_keymap_entry_from_scancode(wistron_idev->input, code);
1156 1110
1157 if (key) { 1111 if (key) {
1158 switch (key->type) { 1112 switch (key->type) {
1159 case KE_KEY:
1160 report_key(wistron_idev->input, key->keycode);
1161 break;
1162
1163 case KE_SW:
1164 report_switch(wistron_idev->input,
1165 key->sw.code, key->sw.value);
1166 break;
1167
1168 case KE_WIFI: 1113 case KE_WIFI:
1169 if (have_wifi) { 1114 if (have_wifi) {
1170 wifi_enabled = !wifi_enabled; 1115 wifi_enabled = !wifi_enabled;
@@ -1180,7 +1125,9 @@ static void handle_key(u8 code)
1180 break; 1125 break;
1181 1126
1182 default: 1127 default:
1183 BUG(); 1128 sparse_keymap_report_entry(wistron_idev->input,
1129 key, 1, true);
1130 break;
1184 } 1131 }
1185 jiffies_last_press = jiffies; 1132 jiffies_last_press = jiffies;
1186 } else 1133 } else
@@ -1220,42 +1167,39 @@ static void wistron_poll(struct input_polled_dev *dev)
1220 dev->poll_interval = POLL_INTERVAL_DEFAULT; 1167 dev->poll_interval = POLL_INTERVAL_DEFAULT;
1221} 1168}
1222 1169
1223static int wistron_getkeycode(struct input_dev *dev, int scancode, int *keycode) 1170static int __devinit wistron_setup_keymap(struct input_dev *dev,
1171 struct key_entry *entry)
1224{ 1172{
1225 const struct key_entry *key = wistron_get_entry_by_scancode(scancode); 1173 switch (entry->type) {
1226 1174
1227 if (key && key->type == KE_KEY) { 1175 /* if wifi or bluetooth are not available, create normal keys */
1228 *keycode = key->keycode; 1176 case KE_WIFI:
1229 return 0; 1177 if (!have_wifi) {
1230 } 1178 entry->type = KE_KEY;
1231 1179 entry->keycode = KEY_WLAN;
1232 return -EINVAL; 1180 }
1233} 1181 break;
1234 1182
1235static int wistron_setkeycode(struct input_dev *dev, int scancode, int keycode) 1183 case KE_BLUETOOTH:
1236{ 1184 if (!have_bluetooth) {
1237 struct key_entry *key; 1185 entry->type = KE_KEY;
1238 int old_keycode; 1186 entry->keycode = KEY_BLUETOOTH;
1239 1187 }
1240 if (keycode < 0 || keycode > KEY_MAX) 1188 break;
1241 return -EINVAL; 1189
1242 1190 case KE_END:
1243 key = wistron_get_entry_by_scancode(scancode); 1191 if (entry->code & FE_UNTESTED)
1244 if (key && key->type == KE_KEY) { 1192 printk(KERN_WARNING "Untested laptop multimedia keys, "
1245 old_keycode = key->keycode; 1193 "please report success or failure to "
1246 key->keycode = keycode; 1194 "eric.piel@tremplin-utc.net\n");
1247 set_bit(keycode, dev->keybit); 1195 break;
1248 if (!wistron_get_entry_by_keycode(old_keycode))
1249 clear_bit(old_keycode, dev->keybit);
1250 return 0;
1251 } 1196 }
1252 1197
1253 return -EINVAL; 1198 return 0;
1254} 1199}
1255 1200
1256static int __devinit setup_input_dev(void) 1201static int __devinit setup_input_dev(void)
1257{ 1202{
1258 struct key_entry *key;
1259 struct input_dev *input_dev; 1203 struct input_dev *input_dev;
1260 int error; 1204 int error;
1261 1205
@@ -1263,7 +1207,7 @@ static int __devinit setup_input_dev(void)
1263 if (!wistron_idev) 1207 if (!wistron_idev)
1264 return -ENOMEM; 1208 return -ENOMEM;
1265 1209
1266 wistron_idev->flush = wistron_flush; 1210 wistron_idev->open = wistron_flush;
1267 wistron_idev->poll = wistron_poll; 1211 wistron_idev->poll = wistron_poll;
1268 wistron_idev->poll_interval = POLL_INTERVAL_DEFAULT; 1212 wistron_idev->poll_interval = POLL_INTERVAL_DEFAULT;
1269 1213
@@ -1273,56 +1217,21 @@ static int __devinit setup_input_dev(void)
1273 input_dev->id.bustype = BUS_HOST; 1217 input_dev->id.bustype = BUS_HOST;
1274 input_dev->dev.parent = &wistron_device->dev; 1218 input_dev->dev.parent = &wistron_device->dev;
1275 1219
1276 input_dev->getkeycode = wistron_getkeycode; 1220 error = sparse_keymap_setup(input_dev, keymap, wistron_setup_keymap);
1277 input_dev->setkeycode = wistron_setkeycode; 1221 if (error)
1278 1222 goto err_free_dev;
1279 for (key = keymap; key->type != KE_END; key++) {
1280 switch (key->type) {
1281 case KE_KEY:
1282 set_bit(EV_KEY, input_dev->evbit);
1283 set_bit(key->keycode, input_dev->keybit);
1284 break;
1285
1286 case KE_SW:
1287 set_bit(EV_SW, input_dev->evbit);
1288 set_bit(key->sw.code, input_dev->swbit);
1289 break;
1290
1291 /* if wifi or bluetooth are not available, create normal keys */
1292 case KE_WIFI:
1293 if (!have_wifi) {
1294 key->type = KE_KEY;
1295 key->keycode = KEY_WLAN;
1296 key--;
1297 }
1298 break;
1299
1300 case KE_BLUETOOTH:
1301 if (!have_bluetooth) {
1302 key->type = KE_KEY;
1303 key->keycode = KEY_BLUETOOTH;
1304 key--;
1305 }
1306 break;
1307
1308 default:
1309 break;
1310 }
1311 }
1312
1313 /* reads information flags on KE_END */
1314 if (key->code & FE_UNTESTED)
1315 printk(KERN_WARNING "Untested laptop multimedia keys, "
1316 "please report success or failure to eric.piel"
1317 "@tremplin-utc.net\n");
1318 1223
1319 error = input_register_polled_device(wistron_idev); 1224 error = input_register_polled_device(wistron_idev);
1320 if (error) { 1225 if (error)
1321 input_free_polled_device(wistron_idev); 1226 goto err_free_keymap;
1322 return error;
1323 }
1324 1227
1325 return 0; 1228 return 0;
1229
1230 err_free_keymap:
1231 sparse_keymap_free(input_dev);
1232 err_free_dev:
1233 input_free_polled_device(wistron_idev);
1234 return error;
1326} 1235}
1327 1236
1328/* Driver core */ 1237/* Driver core */
@@ -1371,6 +1280,7 @@ static int __devexit wistron_remove(struct platform_device *dev)
1371{ 1280{
1372 wistron_led_remove(); 1281 wistron_led_remove();
1373 input_unregister_polled_device(wistron_idev); 1282 input_unregister_polled_device(wistron_idev);
1283 sparse_keymap_free(wistron_idev->input);
1374 input_free_polled_device(wistron_idev); 1284 input_free_polled_device(wistron_idev);
1375 bios_detach(); 1285 bios_detach();
1376 1286