@@ -158,20 +158,20 @@ struct pidff_usage {
158158struct pidff_device {
159159 struct hid_device * hid ;
160160
161- struct hid_report * reports [sizeof (pidff_reports )];
161+ struct hid_report * reports [ARRAY_SIZE (pidff_reports )];
162162
163- struct pidff_usage set_effect [sizeof (pidff_set_effect )];
164- struct pidff_usage set_envelope [sizeof (pidff_set_envelope )];
165- struct pidff_usage set_condition [sizeof (pidff_set_condition )];
166- struct pidff_usage set_periodic [sizeof (pidff_set_periodic )];
167- struct pidff_usage set_constant [sizeof (pidff_set_constant )];
168- struct pidff_usage set_ramp [sizeof (pidff_set_ramp )];
163+ struct pidff_usage set_effect [ARRAY_SIZE (pidff_set_effect )];
164+ struct pidff_usage set_envelope [ARRAY_SIZE (pidff_set_envelope )];
165+ struct pidff_usage set_condition [ARRAY_SIZE (pidff_set_condition )];
166+ struct pidff_usage set_periodic [ARRAY_SIZE (pidff_set_periodic )];
167+ struct pidff_usage set_constant [ARRAY_SIZE (pidff_set_constant )];
168+ struct pidff_usage set_ramp [ARRAY_SIZE (pidff_set_ramp )];
169169
170- struct pidff_usage device_gain [sizeof (pidff_device_gain )];
171- struct pidff_usage block_load [sizeof (pidff_block_load )];
172- struct pidff_usage pool [sizeof (pidff_pool )];
173- struct pidff_usage effect_operation [sizeof (pidff_effect_operation )];
174- struct pidff_usage block_free [sizeof (pidff_block_free )];
170+ struct pidff_usage device_gain [ARRAY_SIZE (pidff_device_gain )];
171+ struct pidff_usage block_load [ARRAY_SIZE (pidff_block_load )];
172+ struct pidff_usage pool [ARRAY_SIZE (pidff_pool )];
173+ struct pidff_usage effect_operation [ARRAY_SIZE (pidff_effect_operation )];
174+ struct pidff_usage block_free [ARRAY_SIZE (pidff_block_free )];
175175
176176 /*
177177 * Special field is a field that is not composed of
@@ -194,10 +194,10 @@ struct pidff_device {
194194 /* Special field in effect_operation */
195195 struct hid_field * effect_operation_status ;
196196
197- int control_id [sizeof (pidff_device_control )];
198- int type_id [sizeof (pidff_effect_types )];
199- int status_id [sizeof (pidff_block_load_status )];
200- int operation_id [sizeof (pidff_effect_operation_status )];
197+ int control_id [ARRAY_SIZE (pidff_device_control )];
198+ int type_id [ARRAY_SIZE (pidff_effect_types )];
199+ int status_id [ARRAY_SIZE (pidff_block_load_status )];
200+ int operation_id [ARRAY_SIZE (pidff_effect_operation_status )];
201201
202202 int pid_id [PID_EFFECTS_MAX ];
203203
@@ -583,7 +583,7 @@ static void pidff_set_device_control(struct pidff_device *pidff, int field)
583583 hid_dbg (pidff -> hid , "DEVICE_CONTROL is a bitmask\n" );
584584
585585 /* Clear current bitmask */
586- for (i = 0 ; i < sizeof (pidff_device_control ); i ++ ) {
586+ for (i = 0 ; i < ARRAY_SIZE (pidff_device_control ); i ++ ) {
587587 index = pidff -> control_id [i ];
588588 if (index < 1 )
589589 continue ;
@@ -999,7 +999,7 @@ static int pidff_check_usage(int usage)
999999{
10001000 int i ;
10011001
1002- for (i = 0 ; i < sizeof (pidff_reports ); i ++ )
1002+ for (i = 0 ; i < ARRAY_SIZE (pidff_reports ); i ++ )
10031003 if (usage == (HID_UP_PID | pidff_reports [i ]))
10041004 return i ;
10051005
@@ -1117,7 +1117,7 @@ static int pidff_find_special_keys(int *keys, struct hid_field *fld,
11171117
11181118#define PIDFF_FIND_SPECIAL_KEYS (keys , field , name ) \
11191119 pidff_find_special_keys(pidff->keys, pidff->field, pidff_ ## name, \
1120- sizeof (pidff_ ## name))
1120+ ARRAY_SIZE (pidff_ ## name))
11211121
11221122/*
11231123 * Find and check the special fields
@@ -1184,15 +1184,15 @@ static int pidff_find_special_fields(struct pidff_device *pidff)
11841184
11851185 if (PIDFF_FIND_SPECIAL_KEYS (status_id , block_load_status ,
11861186 block_load_status ) !=
1187- sizeof (pidff_block_load_status )) {
1187+ ARRAY_SIZE (pidff_block_load_status )) {
11881188 hid_err (pidff -> hid ,
11891189 "block load status identifiers not found\n" );
11901190 return -1 ;
11911191 }
11921192
11931193 if (PIDFF_FIND_SPECIAL_KEYS (operation_id , effect_operation_status ,
11941194 effect_operation_status ) !=
1195- sizeof (pidff_effect_operation_status )) {
1195+ ARRAY_SIZE (pidff_effect_operation_status )) {
11961196 hid_err (pidff -> hid , "effect operation identifiers not found\n" );
11971197 return -1 ;
11981198 }
@@ -1208,7 +1208,7 @@ static int pidff_find_effects(struct pidff_device *pidff,
12081208{
12091209 int i ;
12101210
1211- for (i = 0 ; i < sizeof (pidff_effect_types ); i ++ ) {
1211+ for (i = 0 ; i < ARRAY_SIZE (pidff_effect_types ); i ++ ) {
12121212 int pidff_type = pidff -> type_id [i ];
12131213
12141214 if (pidff -> set_effect_type -> usage [pidff_type ].hid !=
@@ -1258,7 +1258,7 @@ static int pidff_find_effects(struct pidff_device *pidff,
12581258#define PIDFF_FIND_FIELDS (name , report , strict ) \
12591259 pidff_find_fields(pidff->name, pidff_ ## name, \
12601260 pidff->reports[report], \
1261- sizeof (pidff_ ## name), strict)
1261+ ARRAY_SIZE (pidff_ ## name), strict)
12621262
12631263/*
12641264 * Fill and check the pidff_usages
0 commit comments