diff options
Diffstat (limited to 'drivers/platform/x86')
-rw-r--r-- | drivers/platform/x86/hp-wmi.c | 69 |
1 files changed, 30 insertions, 39 deletions
diff --git a/drivers/platform/x86/hp-wmi.c b/drivers/platform/x86/hp-wmi.c index be9227dd82be..45cacf79f3a7 100644 --- a/drivers/platform/x86/hp-wmi.c +++ b/drivers/platform/x86/hp-wmi.c | |||
@@ -73,10 +73,6 @@ enum hp_wmi_event_ids { | |||
73 | HPWMI_LOCK_SWITCH = 7, | 73 | HPWMI_LOCK_SWITCH = 7, |
74 | }; | 74 | }; |
75 | 75 | ||
76 | static int hp_wmi_bios_setup(struct platform_device *device); | ||
77 | static int __exit hp_wmi_bios_remove(struct platform_device *device); | ||
78 | static int hp_wmi_resume_handler(struct device *device); | ||
79 | |||
80 | struct bios_args { | 76 | struct bios_args { |
81 | u32 signature; | 77 | u32 signature; |
82 | u32 command; | 78 | u32 command; |
@@ -160,21 +156,6 @@ struct rfkill2_device { | |||
160 | static int rfkill2_count; | 156 | static int rfkill2_count; |
161 | static struct rfkill2_device rfkill2[HPWMI_MAX_RFKILL2_DEVICES]; | 157 | static struct rfkill2_device rfkill2[HPWMI_MAX_RFKILL2_DEVICES]; |
162 | 158 | ||
163 | static const struct dev_pm_ops hp_wmi_pm_ops = { | ||
164 | .resume = hp_wmi_resume_handler, | ||
165 | .restore = hp_wmi_resume_handler, | ||
166 | }; | ||
167 | |||
168 | static struct platform_driver hp_wmi_driver = { | ||
169 | .driver = { | ||
170 | .name = "hp-wmi", | ||
171 | .owner = THIS_MODULE, | ||
172 | .pm = &hp_wmi_pm_ops, | ||
173 | }, | ||
174 | .probe = hp_wmi_bios_setup, | ||
175 | .remove = hp_wmi_bios_remove, | ||
176 | }; | ||
177 | |||
178 | /* | 159 | /* |
179 | * hp_wmi_perform_query | 160 | * hp_wmi_perform_query |
180 | * | 161 | * |
@@ -812,7 +793,7 @@ fail: | |||
812 | return err; | 793 | return err; |
813 | } | 794 | } |
814 | 795 | ||
815 | static int hp_wmi_bios_setup(struct platform_device *device) | 796 | static int __init hp_wmi_bios_setup(struct platform_device *device) |
816 | { | 797 | { |
817 | int err; | 798 | int err; |
818 | 799 | ||
@@ -917,12 +898,29 @@ static int hp_wmi_resume_handler(struct device *device) | |||
917 | return 0; | 898 | return 0; |
918 | } | 899 | } |
919 | 900 | ||
901 | static const struct dev_pm_ops hp_wmi_pm_ops = { | ||
902 | .resume = hp_wmi_resume_handler, | ||
903 | .restore = hp_wmi_resume_handler, | ||
904 | }; | ||
905 | |||
906 | static struct platform_driver hp_wmi_driver = { | ||
907 | .driver = { | ||
908 | .name = "hp-wmi", | ||
909 | .owner = THIS_MODULE, | ||
910 | .pm = &hp_wmi_pm_ops, | ||
911 | }, | ||
912 | .remove = __exit_p(hp_wmi_bios_remove), | ||
913 | }; | ||
914 | |||
920 | static int __init hp_wmi_init(void) | 915 | static int __init hp_wmi_init(void) |
921 | { | 916 | { |
922 | int err; | 917 | int err; |
923 | int event_capable = wmi_has_guid(HPWMI_EVENT_GUID); | 918 | int event_capable = wmi_has_guid(HPWMI_EVENT_GUID); |
924 | int bios_capable = wmi_has_guid(HPWMI_BIOS_GUID); | 919 | int bios_capable = wmi_has_guid(HPWMI_BIOS_GUID); |
925 | 920 | ||
921 | if (!bios_capable && !event_capable) | ||
922 | return -ENODEV; | ||
923 | |||
926 | if (event_capable) { | 924 | if (event_capable) { |
927 | err = hp_wmi_input_setup(); | 925 | err = hp_wmi_input_setup(); |
928 | if (err) | 926 | if (err) |
@@ -933,34 +931,29 @@ static int __init hp_wmi_init(void) | |||
933 | } | 931 | } |
934 | 932 | ||
935 | if (bios_capable) { | 933 | if (bios_capable) { |
936 | err = platform_driver_register(&hp_wmi_driver); | 934 | hp_wmi_platform_dev = |
937 | if (err) | 935 | platform_device_register_simple("hp-wmi", -1, NULL, 0); |
938 | goto err_driver_reg; | 936 | if (IS_ERR(hp_wmi_platform_dev)) { |
939 | hp_wmi_platform_dev = platform_device_alloc("hp-wmi", -1); | 937 | err = PTR_ERR(hp_wmi_platform_dev); |
940 | if (!hp_wmi_platform_dev) { | 938 | goto err_destroy_input; |
941 | err = -ENOMEM; | ||
942 | goto err_device_alloc; | ||
943 | } | 939 | } |
944 | err = platform_device_add(hp_wmi_platform_dev); | 940 | |
941 | err = platform_driver_probe(&hp_wmi_driver, hp_wmi_bios_setup); | ||
945 | if (err) | 942 | if (err) |
946 | goto err_device_add; | 943 | goto err_unregister_device; |
947 | } | 944 | } |
948 | 945 | ||
949 | if (!bios_capable && !event_capable) | ||
950 | return -ENODEV; | ||
951 | |||
952 | return 0; | 946 | return 0; |
953 | 947 | ||
954 | err_device_add: | 948 | err_unregister_device: |
955 | platform_device_put(hp_wmi_platform_dev); | 949 | platform_device_unregister(hp_wmi_platform_dev); |
956 | err_device_alloc: | 950 | err_destroy_input: |
957 | platform_driver_unregister(&hp_wmi_driver); | ||
958 | err_driver_reg: | ||
959 | if (event_capable) | 951 | if (event_capable) |
960 | hp_wmi_input_destroy(); | 952 | hp_wmi_input_destroy(); |
961 | 953 | ||
962 | return err; | 954 | return err; |
963 | } | 955 | } |
956 | module_init(hp_wmi_init); | ||
964 | 957 | ||
965 | static void __exit hp_wmi_exit(void) | 958 | static void __exit hp_wmi_exit(void) |
966 | { | 959 | { |
@@ -972,6 +965,4 @@ static void __exit hp_wmi_exit(void) | |||
972 | platform_driver_unregister(&hp_wmi_driver); | 965 | platform_driver_unregister(&hp_wmi_driver); |
973 | } | 966 | } |
974 | } | 967 | } |
975 | |||
976 | module_init(hp_wmi_init); | ||
977 | module_exit(hp_wmi_exit); | 968 | module_exit(hp_wmi_exit); |