@@ -709,6 +709,28 @@ static int lg_g15_register_led(struct lg_g15_data *g15, int i)
709
709
return devm_led_classdev_register (& g15 -> hdev -> dev , & g15 -> leds [i ].cdev );
710
710
}
711
711
712
+ /* Common input device init code shared between keyboards and Z-10 speaker handling */
713
+ static void lg_g15_init_input_dev (struct hid_device * hdev , struct input_dev * input ,
714
+ const char * name )
715
+ {
716
+ int i ;
717
+
718
+ input -> name = name ;
719
+ input -> phys = hdev -> phys ;
720
+ input -> uniq = hdev -> uniq ;
721
+ input -> id .bustype = hdev -> bus ;
722
+ input -> id .vendor = hdev -> vendor ;
723
+ input -> id .product = hdev -> product ;
724
+ input -> id .version = hdev -> version ;
725
+ input -> dev .parent = & hdev -> dev ;
726
+ input -> open = lg_g15_input_open ;
727
+ input -> close = lg_g15_input_close ;
728
+
729
+ /* Keys below the LCD, intended for controlling a menu on the LCD */
730
+ for (i = 0 ; i < 5 ; i ++ )
731
+ input_set_capability (input , EV_KEY , KEY_KBD_LCD_MENU1 + i );
732
+ }
733
+
712
734
static int lg_g15_probe (struct hid_device * hdev , const struct hid_device_id * id )
713
735
{
714
736
u8 gkeys_settings_output_report = 0 ;
@@ -751,6 +773,8 @@ static int lg_g15_probe(struct hid_device *hdev, const struct hid_device_id *id)
751
773
752
774
g15 -> hdev = hdev ;
753
775
g15 -> model = id -> driver_data ;
776
+ g15 -> input = input ;
777
+ input_set_drvdata (input , hdev );
754
778
hid_set_drvdata (hdev , (void * )g15 );
755
779
756
780
switch (g15 -> model ) {
@@ -822,16 +846,7 @@ static int lg_g15_probe(struct hid_device *hdev, const struct hid_device_id *id)
822
846
goto error_hw_stop ;
823
847
824
848
/* Setup and register input device */
825
- input -> name = "Logitech Gaming Keyboard Gaming Keys" ;
826
- input -> phys = hdev -> phys ;
827
- input -> uniq = hdev -> uniq ;
828
- input -> id .bustype = hdev -> bus ;
829
- input -> id .vendor = hdev -> vendor ;
830
- input -> id .product = hdev -> product ;
831
- input -> id .version = hdev -> version ;
832
- input -> dev .parent = & hdev -> dev ;
833
- input -> open = lg_g15_input_open ;
834
- input -> close = lg_g15_input_close ;
849
+ lg_g15_init_input_dev (hdev , input , "Logitech Gaming Keyboard Gaming Keys" );
835
850
836
851
/* G-keys */
837
852
for (i = 0 ; i < gkeys ; i ++ )
@@ -842,10 +857,6 @@ static int lg_g15_probe(struct hid_device *hdev, const struct hid_device_id *id)
842
857
input_set_capability (input , EV_KEY , KEY_MACRO_PRESET1 + i );
843
858
input_set_capability (input , EV_KEY , KEY_MACRO_RECORD_START );
844
859
845
- /* Keys below the LCD, intended for controlling a menu on the LCD */
846
- for (i = 0 ; i < 5 ; i ++ )
847
- input_set_capability (input , EV_KEY , KEY_KBD_LCD_MENU1 + i );
848
-
849
860
/*
850
861
* On the G510 only report headphone and mic mute keys when *not* using
851
862
* the builtin USB audio device. When the builtin audio is used these
@@ -857,9 +868,6 @@ static int lg_g15_probe(struct hid_device *hdev, const struct hid_device_id *id)
857
868
input_set_capability (input , EV_KEY , KEY_F20 );
858
869
}
859
870
860
- g15 -> input = input ;
861
- input_set_drvdata (input , hdev );
862
-
863
871
ret = input_register_device (input );
864
872
if (ret )
865
873
goto error_hw_stop ;
0 commit comments