@@ -128,16 +128,20 @@ struct descriptor_resource {
128128 u32 data [];
129129};
130130
131+ struct iso_resource_params {
132+ int generation ;
133+ u64 channels ;
134+ s32 bandwidth ;
135+ };
136+
131137struct iso_resource {
132138 struct client_resource resource ;
133139 struct client * client ;
134140 /* Schedule work and access todo only with client->lock held. */
135141 struct delayed_work work ;
136142 enum {ISO_RES_ALLOC , ISO_RES_REALLOC , ISO_RES_DEALLOC ,
137143 ISO_RES_ALLOC_ONCE , ISO_RES_DEALLOC_ONCE ,} todo ;
138- int generation ;
139- u64 channels ;
140- s32 bandwidth ;
144+ struct iso_resource_params params ;
141145 struct iso_resource_event * e_alloc , * e_dealloc ;
142146};
143147
@@ -1290,6 +1294,20 @@ static int ioctl_get_cycle_timer(struct client *client, union ioctl_arg *arg)
12901294 return 0 ;
12911295}
12921296
1297+ static int fill_iso_resource_params (struct iso_resource_params * params ,
1298+ struct fw_cdev_allocate_iso_resource * request )
1299+ {
1300+ if ((request -> channels == 0 && request -> bandwidth == 0 ) ||
1301+ request -> bandwidth > BANDWIDTH_AVAILABLE_INITIAL )
1302+ return - EINVAL ;
1303+
1304+ params -> generation = -1 ;
1305+ params -> channels = request -> channels ;
1306+ params -> bandwidth = request -> bandwidth ;
1307+
1308+ return 0 ;
1309+ }
1310+
12931311static void iso_resource_work (struct work_struct * work )
12941312{
12951313 struct iso_resource_event * e ;
@@ -1310,21 +1328,21 @@ static void iso_resource_work(struct work_struct *work)
13101328 } else {
13111329 // We could be called twice within the same generation.
13121330 skip = todo == ISO_RES_REALLOC &&
1313- r -> generation == generation ;
1331+ r -> params . generation == generation ;
13141332 }
13151333 free = todo == ISO_RES_DEALLOC ||
13161334 todo == ISO_RES_ALLOC_ONCE ||
13171335 todo == ISO_RES_DEALLOC_ONCE ;
1318- r -> generation = generation ;
1336+ r -> params . generation = generation ;
13191337 }
13201338
13211339 if (skip )
13221340 goto out ;
13231341
1324- bandwidth = r -> bandwidth ;
1342+ bandwidth = r -> params . bandwidth ;
13251343
13261344 fw_iso_resource_manage (client -> device -> card , generation ,
1327- r -> channels , & channel , & bandwidth ,
1345+ r -> params . channels , & channel , & bandwidth ,
13281346 todo == ISO_RES_ALLOC ||
13291347 todo == ISO_RES_REALLOC ||
13301348 todo == ISO_RES_ALLOC_ONCE );
@@ -1355,7 +1373,7 @@ static void iso_resource_work(struct work_struct *work)
13551373 }
13561374
13571375 if (todo == ISO_RES_ALLOC && channel >= 0 )
1358- r -> channels = 1ULL << channel ;
1376+ r -> params . channels = 1ULL << channel ;
13591377
13601378 if (todo == ISO_RES_REALLOC && success )
13611379 goto out ;
@@ -1402,10 +1420,6 @@ static int init_iso_resource(struct client *client,
14021420 struct iso_resource * r ;
14031421 int ret ;
14041422
1405- if ((request -> channels == 0 && request -> bandwidth == 0 ) ||
1406- request -> bandwidth > BANDWIDTH_AVAILABLE_INITIAL )
1407- return - EINVAL ;
1408-
14091423 r = kmalloc_obj (* r );
14101424 e1 = kmalloc_obj (* e1 );
14111425 e2 = kmalloc_obj (* e2 );
@@ -1414,12 +1428,13 @@ static int init_iso_resource(struct client *client,
14141428 goto fail ;
14151429 }
14161430
1431+ ret = fill_iso_resource_params (& r -> params , request );
1432+ if (ret < 0 )
1433+ goto fail ;
1434+
14171435 INIT_DELAYED_WORK (& r -> work , iso_resource_work );
14181436 r -> client = client ;
14191437 r -> todo = todo ;
1420- r -> generation = -1 ;
1421- r -> channels = request -> channels ;
1422- r -> bandwidth = request -> bandwidth ;
14231438 r -> e_alloc = e1 ;
14241439 r -> e_dealloc = e2 ;
14251440
0 commit comments