99#define pr_fmt (fmt ) KBUILD_MODNAME ": " fmt
1010
1111#include "hid-pidff.h"
12+ #include <linux/hid.h>
1213#include <linux/input.h>
14+ #include <linux/minmax.h>
1315#include <linux/slab.h>
1416#include <linux/usb.h>
15- #include <linux/hid.h>
16- #include <linux/minmax.h>
17-
1817
1918#define PID_EFFECTS_MAX 64
2019#define PID_INFINITE U16_MAX
@@ -285,7 +284,7 @@ static s32 pidff_clamp(s32 i, struct hid_field *field)
285284static int pidff_rescale (int i , int max , struct hid_field * field )
286285{
287286 return i * (field -> logical_maximum - field -> logical_minimum ) / max +
288- field -> logical_minimum ;
287+ field -> logical_minimum ;
289288}
290289
291290/*
@@ -329,18 +328,18 @@ static void pidff_set_signed(struct pidff_usage *usage, s16 value)
329328 else {
330329 if (value < 0 )
331330 usage -> value [0 ] =
332- pidff_rescale (- value , - S16_MIN , usage -> field );
331+ pidff_rescale (- value , - S16_MIN , usage -> field );
333332 else
334333 usage -> value [0 ] =
335- pidff_rescale (value , S16_MAX , usage -> field );
334+ pidff_rescale (value , S16_MAX , usage -> field );
336335 }
337336 pr_debug ("calculated from %d to %d\n" , value , usage -> value [0 ]);
338337}
339338
340339static void pidff_set_time (struct pidff_usage * usage , u16 time )
341340{
342- usage -> value [0 ] = pidff_clamp (
343- pidff_rescale_time ( time , usage -> field ), usage -> field );
341+ usage -> value [0 ] = pidff_clamp (pidff_rescale_time ( time , usage -> field ),
342+ usage -> field );
344343}
345344
346345static void pidff_set_duration (struct pidff_usage * usage , u16 duration )
@@ -463,11 +462,11 @@ static void pidff_set_effect_report(struct pidff_device *pidff,
463462 pidff_get_effect_type_id (pidff , effect );
464463
465464 pidff_set_duration (& pidff -> set_effect [PID_DURATION ],
466- effect -> replay .length );
465+ effect -> replay .length );
467466
468467 pidff -> set_effect [PID_TRIGGER_BUTTON ].value [0 ] = effect -> trigger .button ;
469468 pidff_set_time (& pidff -> set_effect [PID_TRIGGER_REPEAT_INT ],
470- effect -> trigger .interval );
469+ effect -> trigger .interval );
471470 pidff -> set_effect [PID_GAIN ].value [0 ] =
472471 pidff -> set_effect [PID_GAIN ].field -> logical_maximum ;
473472 pidff -> set_effect [PID_DIRECTION_ENABLE ].value [0 ] = 1 ;
@@ -477,10 +476,10 @@ static void pidff_set_effect_report(struct pidff_device *pidff,
477476 /* Omit setting delay field if it's missing */
478477 if (!(pidff -> quirks & HID_PIDFF_QUIRK_MISSING_DELAY ))
479478 pidff_set_time (& pidff -> set_effect [PID_START_DELAY ],
480- effect -> replay .delay );
479+ effect -> replay .delay );
481480
482481 hid_hw_request (pidff -> hid , pidff -> reports [PID_SET_EFFECT ],
483- HID_REQ_SET_REPORT );
482+ HID_REQ_SET_REPORT );
484483}
485484
486485/*
@@ -510,10 +509,10 @@ static void pidff_set_periodic_report(struct pidff_device *pidff,
510509 effect -> u .periodic .offset );
511510 pidff_set (& pidff -> set_periodic [PID_PHASE ], effect -> u .periodic .phase );
512511 pidff_set_time (& pidff -> set_periodic [PID_PERIOD ],
513- effect -> u .periodic .period );
512+ effect -> u .periodic .period );
514513
515514 hid_hw_request (pidff -> hid , pidff -> reports [PID_SET_PERIODIC ],
516- HID_REQ_SET_REPORT );
515+ HID_REQ_SET_REPORT );
517516}
518517
519518/*
@@ -560,7 +559,7 @@ static void pidff_set_condition_report(struct pidff_device *pidff,
560559 pidff_set (& pidff -> set_condition [PID_DEAD_BAND ],
561560 effect -> u .condition [i ].deadband );
562561 hid_hw_request (pidff -> hid , pidff -> reports [PID_SET_CONDITION ],
563- HID_REQ_SET_REPORT );
562+ HID_REQ_SET_REPORT );
564563 }
565564}
566565
@@ -623,7 +622,7 @@ static void pidff_set_gain_report(struct pidff_device *pidff, u16 gain)
623622
624623 pidff_set (& pidff -> device_gain [PID_DEVICE_GAIN_FIELD ], gain );
625624 hid_hw_request (pidff -> hid , pidff -> reports [PID_DEVICE_GAIN ],
626- HID_REQ_SET_REPORT );
625+ HID_REQ_SET_REPORT );
627626}
628627
629628/*
@@ -717,21 +716,19 @@ static void pidff_fetch_pool(struct pidff_device *pidff)
717716 */
718717static int pidff_request_effect_upload (struct pidff_device * pidff , int efnum )
719718{
720- int j ;
721-
722719 pidff -> create_new_effect_type -> value [0 ] = efnum ;
723720 hid_hw_request (pidff -> hid , pidff -> reports [PID_CREATE_NEW_EFFECT ],
724- HID_REQ_SET_REPORT );
721+ HID_REQ_SET_REPORT );
725722 hid_dbg (pidff -> hid , "create_new_effect sent, type: %d\n" , efnum );
726723
727724 pidff -> block_load [PID_EFFECT_BLOCK_INDEX ].value [0 ] = 0 ;
728725 pidff -> block_load_status -> value [0 ] = 0 ;
729726 hid_hw_wait (pidff -> hid );
730727
731- for (j = 0 ; j < 60 ; j ++ ) {
728+ for (int i = 0 ; i < 60 ; i ++ ) {
732729 hid_dbg (pidff -> hid , "pid_block_load requested\n" );
733730 hid_hw_request (pidff -> hid , pidff -> reports [PID_BLOCK_LOAD ],
734- HID_REQ_GET_REPORT );
731+ HID_REQ_GET_REPORT );
735732 hid_hw_wait (pidff -> hid );
736733 if (pidff -> block_load_status -> value [0 ] ==
737734 pidff -> status_id [PID_BLOCK_LOAD_SUCCESS ]) {
@@ -808,8 +805,8 @@ static int pidff_erase_effect(struct input_dev *dev, int effect_id)
808805 struct pidff_device * pidff = dev -> ff -> private ;
809806 int pid_id = pidff -> pid_id [effect_id ];
810807
811- hid_dbg (pidff -> hid , "starting to erase %d/%d\n" ,
812- effect_id , pidff -> pid_id [effect_id ]);
808+ hid_dbg (pidff -> hid , "starting to erase %d/%d\n" , effect_id ,
809+ pidff -> pid_id [effect_id ]);
813810
814811 /*
815812 * Wait for the queue to clear. We do not want
@@ -929,7 +926,7 @@ static void pidff_autocenter(struct pidff_device *pidff, u16 magnitude)
929926 pidff -> set_effect [PID_START_DELAY ].value [0 ] = 0 ;
930927
931928 hid_hw_request (pidff -> hid , pidff -> reports [PID_SET_EFFECT ],
932- HID_REQ_SET_REPORT );
929+ HID_REQ_SET_REPORT );
933930}
934931
935932/*
@@ -1196,15 +1193,15 @@ static int pidff_find_special_fields(struct pidff_device *pidff)
11961193
11971194 if (PIDFF_FIND_SPECIAL_KEYS (status_id , block_load_status ,
11981195 block_load_status ) !=
1199- ARRAY_SIZE (pidff_block_load_status )) {
1196+ ARRAY_SIZE (pidff_block_load_status )) {
12001197 hid_err (pidff -> hid ,
12011198 "block load status identifiers not found\n" );
12021199 return -1 ;
12031200 }
12041201
12051202 if (PIDFF_FIND_SPECIAL_KEYS (operation_id , effect_operation_status ,
12061203 effect_operation_status ) !=
1207- ARRAY_SIZE (pidff_effect_operation_status )) {
1204+ ARRAY_SIZE (pidff_effect_operation_status )) {
12081205 hid_err (pidff -> hid , "effect operation identifiers not found\n" );
12091206 return -1 ;
12101207 }
@@ -1408,8 +1405,8 @@ static int pidff_check_autocenter(struct pidff_device *pidff,
14081405int hid_pidff_init_with_quirks (struct hid_device * hid , u32 initial_quirks )
14091406{
14101407 struct pidff_device * pidff ;
1411- struct hid_input * hidinput = list_entry ( hid -> inputs . next ,
1412- struct hid_input , list );
1408+ struct hid_input * hidinput =
1409+ list_entry ( hid -> inputs . next , struct hid_input , list );
14131410 struct input_dev * dev = hidinput -> input ;
14141411 struct ff_device * ff ;
14151412 int max_effects ;
@@ -1496,7 +1493,7 @@ int hid_pidff_init_with_quirks(struct hid_device *hid, u32 initial_quirks)
14961493
14971494 return 0 ;
14981495
1499- fail :
1496+ fail :
15001497 hid_device_io_stop (hid );
15011498
15021499 kfree (pidff );
0 commit comments