@@ -210,9 +210,7 @@ struct pidff_device {
210210 */
211211static s32 pidff_clamp (s32 i , struct hid_field * field )
212212{
213- s32 clamped = clamp (i , field -> logical_minimum , field -> logical_maximum );
214- pr_debug ("clamped from %d to %d" , i , clamped );
215- return clamped ;
213+ return (s32 )clamp (i , field -> logical_minimum , field -> logical_maximum );
216214}
217215
218216/*
@@ -229,8 +227,10 @@ static int pidff_rescale(int i, int max, struct hid_field *field)
229227 */
230228static int pidff_rescale_signed (int i , struct hid_field * field )
231229{
232- if (i > 0 ) return i * field -> logical_maximum / S16_MAX ;
233- if (i < 0 ) return i * field -> logical_minimum / S16_MIN ;
230+ if (i > 0 )
231+ return i * field -> logical_maximum / S16_MAX ;
232+ if (i < 0 )
233+ return i * field -> logical_minimum / S16_MIN ;
234234 return 0 ;
235235}
236236
@@ -241,11 +241,11 @@ static u32 pidff_rescale_time(u16 time, struct hid_field *field)
241241{
242242 u32 scaled_time = time ;
243243 int exponent = field -> unit_exponent ;
244- pr_debug ("time field exponent: %d\n" , exponent );
245244
246- for (;exponent < FF_TIME_EXPONENT ; exponent ++ )
245+ pr_debug ("time field exponent: %d\n" , exponent );
246+ for (; exponent < FF_TIME_EXPONENT ; exponent ++ )
247247 scaled_time *= 10 ;
248- for (;exponent > FF_TIME_EXPONENT ; exponent -- )
248+ for (; exponent > FF_TIME_EXPONENT ; exponent -- )
249249 scaled_time /= 10 ;
250250
251251 pr_debug ("time calculated from %d to %d\n" , time , scaled_time );
@@ -275,8 +275,8 @@ static void pidff_set_signed(struct pidff_usage *usage, s16 value)
275275
276276static void pidff_set_time (struct pidff_usage * usage , u16 time )
277277{
278- u32 modified_time = pidff_rescale_time ( time , usage -> field );
279- usage -> value [ 0 ] = pidff_clamp ( modified_time , usage -> field );
278+ usage -> value [ 0 ] = pidff_clamp (
279+ pidff_rescale_time ( time , usage -> field ) , usage -> field );
280280}
281281
282282static void pidff_set_duration (struct pidff_usage * usage , u16 duration )
@@ -332,6 +332,7 @@ static int pidff_needs_set_envelope(struct ff_envelope *envelope,
332332 struct ff_envelope * old )
333333{
334334 bool needs_new_envelope ;
335+
335336 needs_new_envelope = envelope -> attack_level != 0 ||
336337 envelope -> fade_level != 0 ||
337338 envelope -> attack_length != 0 ||
@@ -568,7 +569,7 @@ static void pidff_set_device_control(struct pidff_device *pidff, int field)
568569 hid_dbg (pidff -> hid , "DEVICE_CONTROL is a bitmask\n" );
569570
570571 /* Clear current bitmask */
571- for (i = 0 ; i < sizeof (pidff_device_control ); i ++ ) {
572+ for (i = 0 ; i < sizeof (pidff_device_control ); i ++ ) {
572573 index = pidff -> control_id [i ];
573574 if (index < 1 )
574575 continue ;
@@ -619,7 +620,7 @@ static void pidff_fetch_pool(struct pidff_device *pidff)
619620 struct hid_device * hid = pidff -> hid ;
620621
621622 /* Repeat if PID_SIMULTANEOUS_MAX < 2 to make sure it's correct */
622- for (i = 0 ; i < 20 ; i ++ ) {
623+ for (i = 0 ; i < 20 ; i ++ ) {
623624 hid_hw_request (hid , pidff -> reports [PID_POOL ], HID_REQ_GET_REPORT );
624625 hid_hw_wait (hid );
625626
@@ -715,6 +716,7 @@ static void pidff_playback_pid(struct pidff_device *pidff, int pid_id, int n)
715716static int pidff_playback (struct input_dev * dev , int effect_id , int value )
716717{
717718 struct pidff_device * pidff = dev -> ff -> private ;
719+
718720 pidff_playback_pid (pidff , pidff -> pid_id [effect_id ], value );
719721 return 0 ;
720722}
@@ -849,7 +851,7 @@ static int pidff_upload_effect(struct input_dev *dev, struct ff_effect *effect,
849851 case FF_INERTIA :
850852 case FF_FRICTION :
851853 if (!old ) {
852- switch (effect -> type ) {
854+ switch (effect -> type ) {
853855 case FF_SPRING :
854856 type_id = PID_SPRING ;
855857 break ;
@@ -940,7 +942,7 @@ static int pidff_find_fields(struct pidff_usage *usage, const u8 *table,
940942 struct hid_report * report , int count , int strict )
941943{
942944 if (!report ) {
943- pr_debug ("pidff_find_fields , null report\n" );
945+ pr_debug ("%s , null report\n" , __func__ );
944946 return -1 ;
945947 }
946948
@@ -974,13 +976,11 @@ static int pidff_find_fields(struct pidff_usage *usage, const u8 *table,
974976 pr_debug ("Delay field not found, but that's OK\n" );
975977 pr_debug ("Setting MISSING_DELAY quirk\n" );
976978 return_value |= HID_PIDFF_QUIRK_MISSING_DELAY ;
977- }
978- else if (!found && table [k ] == pidff_set_condition [PID_PARAM_BLOCK_OFFSET ]) {
979+ } else if (!found && table [k ] == pidff_set_condition [PID_PARAM_BLOCK_OFFSET ]) {
979980 pr_debug ("PBO field not found, but that's OK\n" );
980981 pr_debug ("Setting MISSING_PBO quirk\n" );
981982 return_value |= HID_PIDFF_QUIRK_MISSING_PBO ;
982- }
983- else if (!found && strict ) {
983+ } else if (!found && strict ) {
984984 pr_debug ("failed to locate %d\n" , k );
985985 return -1 ;
986986 }
@@ -1069,7 +1069,7 @@ static struct hid_field *pidff_find_special_field(struct hid_report *report,
10691069 int usage , int enforce_min )
10701070{
10711071 if (!report ) {
1072- pr_debug ("pidff_find_special_field , null report\n" );
1072+ pr_debug ("%s , null report\n" , __func__ );
10731073 return NULL ;
10741074 }
10751075
@@ -1081,10 +1081,9 @@ static struct hid_field *pidff_find_special_field(struct hid_report *report,
10811081 if (!enforce_min ||
10821082 report -> field [i ]-> logical_minimum == 1 )
10831083 return report -> field [i ];
1084- else {
1085- pr_err ("logical_minimum is not 1 as it should be\n" );
1086- return NULL ;
1087- }
1084+
1085+ pr_err ("logical_minimum is not 1 as it should be\n" );
1086+ return NULL ;
10881087 }
10891088 }
10901089 return NULL ;
@@ -1207,6 +1206,7 @@ static int pidff_find_effects(struct pidff_device *pidff,
12071206
12081207 for (i = 0 ; i < sizeof (pidff_effect_types ); i ++ ) {
12091208 int pidff_type = pidff -> type_id [i ];
1209+
12101210 if (pidff -> set_effect_type -> usage [pidff_type ].hid !=
12111211 pidff -> create_new_effect_type -> usage [pidff_type ].hid ) {
12121212 hid_err (pidff -> hid ,
0 commit comments