@@ -73,10 +73,6 @@ enum hp_wmi_event_ids {
73
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
76
struct bios_args {
81
77
u32 signature ;
82
78
u32 command ;
@@ -160,21 +156,6 @@ struct rfkill2_device {
160
156
static int rfkill2_count ;
161
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
160
* hp_wmi_perform_query
180
161
*
@@ -812,7 +793,7 @@ static int hp_wmi_rfkill2_setup(struct platform_device *device)
812
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
798
int err ;
818
799
@@ -917,12 +898,29 @@ static int hp_wmi_resume_handler(struct device *device)
917
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
915
static int __init hp_wmi_init (void )
921
916
{
922
917
int err ;
923
918
int event_capable = wmi_has_guid (HPWMI_EVENT_GUID );
924
919
int bios_capable = wmi_has_guid (HPWMI_BIOS_GUID );
925
920
921
+ if (!bios_capable && !event_capable )
922
+ return - ENODEV ;
923
+
926
924
if (event_capable ) {
927
925
err = hp_wmi_input_setup ();
928
926
if (err )
@@ -933,34 +931,29 @@ static int __init hp_wmi_init(void)
933
931
}
934
932
935
933
if (bios_capable ) {
936
- err = platform_driver_register (& hp_wmi_driver );
937
- if (err )
938
- goto err_driver_reg ;
939
- hp_wmi_platform_dev = platform_device_alloc ("hp-wmi" , -1 );
940
- if (!hp_wmi_platform_dev ) {
941
- err = - ENOMEM ;
942
- goto err_device_alloc ;
934
+ hp_wmi_platform_dev =
935
+ platform_device_register_simple ("hp-wmi" , -1 , NULL , 0 );
936
+ if (IS_ERR (hp_wmi_platform_dev )) {
937
+ err = PTR_ERR (hp_wmi_platform_dev );
938
+ goto err_destroy_input ;
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
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
946
return 0 ;
953
947
954
- err_device_add :
955
- platform_device_put (hp_wmi_platform_dev );
956
- err_device_alloc :
957
- platform_driver_unregister (& hp_wmi_driver );
958
- err_driver_reg :
948
+ err_unregister_device :
949
+ platform_device_unregister (hp_wmi_platform_dev );
950
+ err_destroy_input :
959
951
if (event_capable )
960
952
hp_wmi_input_destroy ();
961
953
962
954
return err ;
963
955
}
956
+ module_init (hp_wmi_init );
964
957
965
958
static void __exit hp_wmi_exit (void )
966
959
{
@@ -972,6 +965,4 @@ static void __exit hp_wmi_exit(void)
972
965
platform_driver_unregister (& hp_wmi_driver );
973
966
}
974
967
}
975
-
976
- module_init (hp_wmi_init );
977
968
module_exit (hp_wmi_exit );
0 commit comments