@@ -539,6 +539,19 @@ static int pidff_needs_set_ramp(struct ff_effect *effect, struct ff_effect *old)
539
539
effect -> u .ramp .end_level != old -> u .ramp .end_level ;
540
540
}
541
541
542
+ /*
543
+ * Set device gain
544
+ */
545
+ static void pidff_set_gain_report (struct pidff_device * pidff , u16 gain )
546
+ {
547
+ if (!pidff -> device_gain [PID_DEVICE_GAIN_FIELD ].field )
548
+ return ;
549
+
550
+ pidff_set (& pidff -> device_gain [PID_DEVICE_GAIN_FIELD ], gain );
551
+ hid_hw_request (pidff -> hid , pidff -> reports [PID_DEVICE_GAIN ],
552
+ HID_REQ_SET_REPORT );
553
+ }
554
+
542
555
/*
543
556
* Clear device control report
544
557
*/
@@ -865,11 +878,7 @@ static int pidff_upload_effect(struct input_dev *dev, struct ff_effect *effect,
865
878
*/
866
879
static void pidff_set_gain (struct input_dev * dev , u16 gain )
867
880
{
868
- struct pidff_device * pidff = dev -> ff -> private ;
869
-
870
- pidff_set (& pidff -> device_gain [PID_DEVICE_GAIN_FIELD ], gain );
871
- hid_hw_request (pidff -> hid , pidff -> reports [PID_DEVICE_GAIN ],
872
- HID_REQ_SET_REPORT );
881
+ pidff_set_gain_report (dev -> ff -> private , gain );
873
882
}
874
883
875
884
static void pidff_autocenter (struct pidff_device * pidff , u16 magnitude )
@@ -1404,12 +1413,7 @@ int hid_pidff_init_with_quirks(struct hid_device *hid, __u32 initial_quirks)
1404
1413
if (error )
1405
1414
goto fail ;
1406
1415
1407
- if (test_bit (FF_GAIN , dev -> ffbit )) {
1408
- pidff_set (& pidff -> device_gain [PID_DEVICE_GAIN_FIELD ], 0xffff );
1409
- hid_hw_request (hid , pidff -> reports [PID_DEVICE_GAIN ],
1410
- HID_REQ_SET_REPORT );
1411
- }
1412
-
1416
+ pidff_set_gain_report (pidff , 0xffff );
1413
1417
error = pidff_check_autocenter (pidff , dev );
1414
1418
if (error )
1415
1419
goto fail ;
0 commit comments