@@ -102,6 +102,11 @@ enum hp_wmi_command {
102102 HPWMI_ODM = 0x03 ,
103103};
104104
105+ enum hp_wmi_hardware_mask {
106+ HPWMI_DOCK_MASK = 0x01 ,
107+ HPWMI_TABLET_MASK = 0x04 ,
108+ };
109+
105110#define BIOS_ARGS_INIT (write , ctype , size ) \
106111 (struct bios_args) { .signature = 0x55434553, \
107112 .command = (write) ? 0x2 : 0x1, \
@@ -271,7 +276,7 @@ static int hp_wmi_read_int(int query)
271276 return val ;
272277}
273278
274- static int hp_wmi_dock_state ( void )
279+ static int hp_wmi_hw_state ( int mask )
275280{
276281 int state = hp_wmi_read_int (HPWMI_HARDWARE_QUERY );
277282
@@ -281,16 +286,6 @@ static int hp_wmi_dock_state(void)
281286 return state & 0x1 ;
282287}
283288
284- static int hp_wmi_tablet_state (void )
285- {
286- int state = hp_wmi_read_int (HPWMI_HARDWARE_QUERY );
287-
288- if (state < 0 )
289- return state ;
290-
291- return (state & 0x4 ) ? 1 : 0 ;
292- }
293-
294289static int __init hp_wmi_bios_2008_later (void )
295290{
296291 int state = 0 ;
@@ -438,7 +433,7 @@ static ssize_t show_als(struct device *dev, struct device_attribute *attr,
438433static ssize_t show_dock (struct device * dev , struct device_attribute * attr ,
439434 char * buf )
440435{
441- int value = hp_wmi_dock_state ( );
436+ int value = hp_wmi_hw_state ( HPWMI_DOCK_MASK );
442437 if (value < 0 )
443438 return - EINVAL ;
444439 return sprintf (buf , "%d\n" , value );
@@ -447,7 +442,7 @@ static ssize_t show_dock(struct device *dev, struct device_attribute *attr,
447442static ssize_t show_tablet (struct device * dev , struct device_attribute * attr ,
448443 char * buf )
449444{
450- int value = hp_wmi_tablet_state ( );
445+ int value = hp_wmi_hw_state ( HPWMI_TABLET_MASK );
451446 if (value < 0 )
452447 return - EINVAL ;
453448 return sprintf (buf , "%d\n" , value );
@@ -550,10 +545,10 @@ static void hp_wmi_notify(u32 value, void *context)
550545 case HPWMI_DOCK_EVENT :
551546 if (test_bit (SW_DOCK , hp_wmi_input_dev -> swbit ))
552547 input_report_switch (hp_wmi_input_dev , SW_DOCK ,
553- hp_wmi_dock_state ( ));
548+ hp_wmi_hw_state ( HPWMI_DOCK_MASK ));
554549 if (test_bit (SW_TABLET_MODE , hp_wmi_input_dev -> swbit ))
555550 input_report_switch (hp_wmi_input_dev , SW_TABLET_MODE ,
556- hp_wmi_tablet_state ( ));
551+ hp_wmi_hw_state ( HPWMI_TABLET_MASK ));
557552 input_sync (hp_wmi_input_dev );
558553 break ;
559554 case HPWMI_PARK_HDD :
@@ -631,14 +626,14 @@ static int __init hp_wmi_input_setup(void)
631626 __set_bit (EV_SW , hp_wmi_input_dev -> evbit );
632627
633628 /* Dock */
634- val = hp_wmi_dock_state ( );
629+ val = hp_wmi_hw_state ( HPWMI_DOCK_MASK );
635630 if (!(val < 0 )) {
636631 __set_bit (SW_DOCK , hp_wmi_input_dev -> swbit );
637632 input_report_switch (hp_wmi_input_dev , SW_DOCK , val );
638633 }
639634
640635 /* Tablet mode */
641- val = hp_wmi_tablet_state ( );
636+ val = hp_wmi_hw_state ( HPWMI_TABLET_MASK );
642637 if (!(val < 0 )) {
643638 __set_bit (SW_TABLET_MODE , hp_wmi_input_dev -> swbit );
644639 input_report_switch (hp_wmi_input_dev , SW_TABLET_MODE , val );
@@ -932,10 +927,10 @@ static int hp_wmi_resume_handler(struct device *device)
932927 if (hp_wmi_input_dev ) {
933928 if (test_bit (SW_DOCK , hp_wmi_input_dev -> swbit ))
934929 input_report_switch (hp_wmi_input_dev , SW_DOCK ,
935- hp_wmi_dock_state ( ));
930+ hp_wmi_hw_state ( HPWMI_DOCK_MASK ));
936931 if (test_bit (SW_TABLET_MODE , hp_wmi_input_dev -> swbit ))
937932 input_report_switch (hp_wmi_input_dev , SW_TABLET_MODE ,
938- hp_wmi_tablet_state ( ));
933+ hp_wmi_hw_state ( HPWMI_TABLET_MASK ));
939934 input_sync (hp_wmi_input_dev );
940935 }
941936
0 commit comments