@@ -210,9 +210,7 @@ struct pidff_device {
210
210
*/
211
211
static s32 pidff_clamp (s32 i , struct hid_field * field )
212
212
{
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 );
216
214
}
217
215
218
216
/*
@@ -229,8 +227,10 @@ static int pidff_rescale(int i, int max, struct hid_field *field)
229
227
*/
230
228
static int pidff_rescale_signed (int i , struct hid_field * field )
231
229
{
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 ;
234
234
return 0 ;
235
235
}
236
236
@@ -241,11 +241,11 @@ static u32 pidff_rescale_time(u16 time, struct hid_field *field)
241
241
{
242
242
u32 scaled_time = time ;
243
243
int exponent = field -> unit_exponent ;
244
- pr_debug ("time field exponent: %d\n" , exponent );
245
244
246
- for (;exponent < FF_TIME_EXPONENT ; exponent ++ )
245
+ pr_debug ("time field exponent: %d\n" , exponent );
246
+ for (; exponent < FF_TIME_EXPONENT ; exponent ++ )
247
247
scaled_time *= 10 ;
248
- for (;exponent > FF_TIME_EXPONENT ; exponent -- )
248
+ for (; exponent > FF_TIME_EXPONENT ; exponent -- )
249
249
scaled_time /= 10 ;
250
250
251
251
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)
275
275
276
276
static void pidff_set_time (struct pidff_usage * usage , u16 time )
277
277
{
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 );
280
280
}
281
281
282
282
static void pidff_set_duration (struct pidff_usage * usage , u16 duration )
@@ -332,6 +332,7 @@ static int pidff_needs_set_envelope(struct ff_envelope *envelope,
332
332
struct ff_envelope * old )
333
333
{
334
334
bool needs_new_envelope ;
335
+
335
336
needs_new_envelope = envelope -> attack_level != 0 ||
336
337
envelope -> fade_level != 0 ||
337
338
envelope -> attack_length != 0 ||
@@ -568,7 +569,7 @@ static void pidff_set_device_control(struct pidff_device *pidff, int field)
568
569
hid_dbg (pidff -> hid , "DEVICE_CONTROL is a bitmask\n" );
569
570
570
571
/* Clear current bitmask */
571
- for (i = 0 ; i < sizeof (pidff_device_control ); i ++ ) {
572
+ for (i = 0 ; i < sizeof (pidff_device_control ); i ++ ) {
572
573
index = pidff -> control_id [i ];
573
574
if (index < 1 )
574
575
continue ;
@@ -619,7 +620,7 @@ static void pidff_fetch_pool(struct pidff_device *pidff)
619
620
struct hid_device * hid = pidff -> hid ;
620
621
621
622
/* 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 ++ ) {
623
624
hid_hw_request (hid , pidff -> reports [PID_POOL ], HID_REQ_GET_REPORT );
624
625
hid_hw_wait (hid );
625
626
@@ -715,6 +716,7 @@ static void pidff_playback_pid(struct pidff_device *pidff, int pid_id, int n)
715
716
static int pidff_playback (struct input_dev * dev , int effect_id , int value )
716
717
{
717
718
struct pidff_device * pidff = dev -> ff -> private ;
719
+
718
720
pidff_playback_pid (pidff , pidff -> pid_id [effect_id ], value );
719
721
return 0 ;
720
722
}
@@ -849,7 +851,7 @@ static int pidff_upload_effect(struct input_dev *dev, struct ff_effect *effect,
849
851
case FF_INERTIA :
850
852
case FF_FRICTION :
851
853
if (!old ) {
852
- switch (effect -> type ) {
854
+ switch (effect -> type ) {
853
855
case FF_SPRING :
854
856
type_id = PID_SPRING ;
855
857
break ;
@@ -940,7 +942,7 @@ static int pidff_find_fields(struct pidff_usage *usage, const u8 *table,
940
942
struct hid_report * report , int count , int strict )
941
943
{
942
944
if (!report ) {
943
- pr_debug ("pidff_find_fields , null report\n" );
945
+ pr_debug ("%s , null report\n" , __func__ );
944
946
return -1 ;
945
947
}
946
948
@@ -974,13 +976,11 @@ static int pidff_find_fields(struct pidff_usage *usage, const u8 *table,
974
976
pr_debug ("Delay field not found, but that's OK\n" );
975
977
pr_debug ("Setting MISSING_DELAY quirk\n" );
976
978
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 ]) {
979
980
pr_debug ("PBO field not found, but that's OK\n" );
980
981
pr_debug ("Setting MISSING_PBO quirk\n" );
981
982
return_value |= HID_PIDFF_QUIRK_MISSING_PBO ;
982
- }
983
- else if (!found && strict ) {
983
+ } else if (!found && strict ) {
984
984
pr_debug ("failed to locate %d\n" , k );
985
985
return -1 ;
986
986
}
@@ -1069,7 +1069,7 @@ static struct hid_field *pidff_find_special_field(struct hid_report *report,
1069
1069
int usage , int enforce_min )
1070
1070
{
1071
1071
if (!report ) {
1072
- pr_debug ("pidff_find_special_field , null report\n" );
1072
+ pr_debug ("%s , null report\n" , __func__ );
1073
1073
return NULL ;
1074
1074
}
1075
1075
@@ -1081,10 +1081,9 @@ static struct hid_field *pidff_find_special_field(struct hid_report *report,
1081
1081
if (!enforce_min ||
1082
1082
report -> field [i ]-> logical_minimum == 1 )
1083
1083
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 ;
1088
1087
}
1089
1088
}
1090
1089
return NULL ;
@@ -1207,6 +1206,7 @@ static int pidff_find_effects(struct pidff_device *pidff,
1207
1206
1208
1207
for (i = 0 ; i < sizeof (pidff_effect_types ); i ++ ) {
1209
1208
int pidff_type = pidff -> type_id [i ];
1209
+
1210
1210
if (pidff -> set_effect_type -> usage [pidff_type ].hid !=
1211
1211
pidff -> create_new_effect_type -> usage [pidff_type ].hid ) {
1212
1212
hid_err (pidff -> hid ,
0 commit comments