@@ -176,15 +176,9 @@ static int snd_us16x08_recv_urb(struct snd_usb_audio *chip,
176
176
*/
177
177
static int snd_us16x08_send_urb (struct snd_usb_audio * chip , char * buf , int size )
178
178
{
179
- int err = 0 ;
180
-
181
- if (chip ) {
182
- err = snd_usb_ctl_msg (chip -> dev , usb_sndctrlpipe (chip -> dev , 0 ),
179
+ return snd_usb_ctl_msg (chip -> dev , usb_sndctrlpipe (chip -> dev , 0 ),
183
180
SND_US16X08_URB_REQUEST , SND_US16X08_URB_REQUESTTYPE ,
184
181
0 , 0 , buf , size );
185
- }
186
-
187
- return err ;
188
182
}
189
183
190
184
static int snd_us16x08_route_info (struct snd_kcontrol * kcontrol ,
@@ -212,10 +206,7 @@ static int snd_us16x08_route_put(struct snd_kcontrol *kcontrol,
212
206
struct snd_usb_audio * chip = elem -> head .mixer -> chip ;
213
207
int index = ucontrol -> id .index ;
214
208
char buf [sizeof (route_msg )];
215
- int val , val_org , err = 0 ;
216
-
217
- /* prepare the message buffer from template */
218
- memcpy (buf , route_msg , sizeof (route_msg ));
209
+ int val , val_org , err ;
219
210
220
211
/* get the new value (no bias for routes) */
221
212
val = ucontrol -> value .enumerated .item [0 ];
@@ -224,6 +215,9 @@ static int snd_us16x08_route_put(struct snd_kcontrol *kcontrol,
224
215
if (val < 0 || val > 9 )
225
216
return - EINVAL ;
226
217
218
+ /* prepare the message buffer from template */
219
+ memcpy (buf , route_msg , sizeof (route_msg ));
220
+
227
221
if (val < 2 ) {
228
222
/* input comes from a master channel */
229
223
val_org = val ;
@@ -279,12 +273,9 @@ static int snd_us16x08_master_put(struct snd_kcontrol *kcontrol,
279
273
struct usb_mixer_elem_info * elem = kcontrol -> private_data ;
280
274
struct snd_usb_audio * chip = elem -> head .mixer -> chip ;
281
275
char buf [sizeof (mix_msg_out )];
282
- int val , err = 0 ;
276
+ int val , err ;
283
277
int index = ucontrol -> id .index ;
284
278
285
- /* prepare the message buffer from template */
286
- memcpy (buf , mix_msg_out , sizeof (mix_msg_out ));
287
-
288
279
/* new control value incl. bias*/
289
280
val = ucontrol -> value .integer .value [0 ];
290
281
@@ -293,6 +284,9 @@ static int snd_us16x08_master_put(struct snd_kcontrol *kcontrol,
293
284
|| val > SND_US16X08_KCMAX (kcontrol ))
294
285
return - EINVAL ;
295
286
287
+ /* prepare the message buffer from template */
288
+ memcpy (buf , mix_msg_out , sizeof (mix_msg_out ));
289
+
296
290
buf [8 ] = val - SND_US16X08_KCBIAS (kcontrol );
297
291
buf [6 ] = elem -> head .id ;
298
292
@@ -392,16 +386,16 @@ static int snd_us16x08_channel_put(struct snd_kcontrol *kcontrol,
392
386
int val , err ;
393
387
int index = ucontrol -> id .index ;
394
388
395
- /* prepare URB message from template */
396
- memcpy (buf , mix_msg_in , sizeof (mix_msg_in ));
397
-
398
389
val = ucontrol -> value .integer .value [0 ];
399
390
400
391
/* sanity check */
401
392
if (val < SND_US16X08_KCMIN (kcontrol )
402
393
|| val > SND_US16X08_KCMAX (kcontrol ))
403
394
return - EINVAL ;
404
395
396
+ /* prepare URB message from template */
397
+ memcpy (buf , mix_msg_in , sizeof (mix_msg_in ));
398
+
405
399
/* add the bias to the new value */
406
400
buf [8 ] = val - SND_US16X08_KCBIAS (kcontrol );
407
401
buf [6 ] = elem -> head .id ;
@@ -434,8 +428,7 @@ static int snd_us16x08_comp_get(struct snd_kcontrol *kcontrol,
434
428
struct snd_ctl_elem_value * ucontrol )
435
429
{
436
430
struct usb_mixer_elem_info * elem = kcontrol -> private_data ;
437
- struct snd_us16x08_comp_store * store =
438
- ((struct snd_us16x08_comp_store * ) elem -> private_data );
431
+ struct snd_us16x08_comp_store * store = elem -> private_data ;
439
432
int index = ucontrol -> id .index ;
440
433
int val_idx = COMP_STORE_IDX (elem -> head .id );
441
434
@@ -449,18 +442,11 @@ static int snd_us16x08_comp_put(struct snd_kcontrol *kcontrol,
449
442
{
450
443
struct usb_mixer_elem_info * elem = kcontrol -> private_data ;
451
444
struct snd_usb_audio * chip = elem -> head .mixer -> chip ;
452
- struct snd_us16x08_comp_store * store =
453
- ((struct snd_us16x08_comp_store * ) elem -> private_data );
445
+ struct snd_us16x08_comp_store * store = elem -> private_data ;
454
446
int index = ucontrol -> id .index ;
455
447
char buf [sizeof (comp_msg )];
456
448
int val_idx , val ;
457
- int err = 0 ;
458
-
459
- /* prepare compressor URB message from template */
460
- memcpy (buf , comp_msg , sizeof (comp_msg ));
461
-
462
- /* new control value incl. bias*/
463
- val_idx = elem -> head .id - SND_US16X08_ID_COMP_BASE ;
449
+ int err ;
464
450
465
451
val = ucontrol -> value .integer .value [0 ];
466
452
@@ -469,8 +455,14 @@ static int snd_us16x08_comp_put(struct snd_kcontrol *kcontrol,
469
455
|| val > SND_US16X08_KCMAX (kcontrol ))
470
456
return - EINVAL ;
471
457
458
+ /* new control value incl. bias*/
459
+ val_idx = elem -> head .id - SND_US16X08_ID_COMP_BASE ;
460
+
472
461
store -> val [val_idx ][index ] = ucontrol -> value .integer .value [0 ];
473
462
463
+ /* prepare compressor URB message from template */
464
+ memcpy (buf , comp_msg , sizeof (comp_msg ));
465
+
474
466
/* place comp values in message buffer watch bias! */
475
467
buf [8 ] = store -> val [
476
468
COMP_STORE_IDX (SND_US16X08_ID_COMP_THRESHOLD )][index ]
@@ -502,10 +494,9 @@ static int snd_us16x08_comp_put(struct snd_kcontrol *kcontrol,
502
494
static int snd_us16x08_eqswitch_get (struct snd_kcontrol * kcontrol ,
503
495
struct snd_ctl_elem_value * ucontrol )
504
496
{
505
- int val = 0 ;
497
+ int val ;
506
498
struct usb_mixer_elem_info * elem = kcontrol -> private_data ;
507
- struct snd_us16x08_eq_store * store =
508
- ((struct snd_us16x08_eq_store * ) elem -> private_data );
499
+ struct snd_us16x08_eq_store * store = elem -> private_data ;
509
500
int index = ucontrol -> id .index ;
510
501
511
502
/* get low switch from cache is enough, cause all bands are together */
@@ -521,10 +512,8 @@ static int snd_us16x08_eqswitch_put(struct snd_kcontrol *kcontrol,
521
512
{
522
513
struct usb_mixer_elem_info * elem = kcontrol -> private_data ;
523
514
struct snd_usb_audio * chip = elem -> head .mixer -> chip ;
524
- struct snd_us16x08_eq_store * store =
525
- ((struct snd_us16x08_eq_store * ) elem -> private_data );
515
+ struct snd_us16x08_eq_store * store = elem -> private_data ;
526
516
int index = ucontrol -> id .index ;
527
-
528
517
char buf [sizeof (eqs_msq )];
529
518
int val , err = 0 ;
530
519
int b_idx ;
@@ -564,10 +553,9 @@ static int snd_us16x08_eqswitch_put(struct snd_kcontrol *kcontrol,
564
553
static int snd_us16x08_eq_get (struct snd_kcontrol * kcontrol ,
565
554
struct snd_ctl_elem_value * ucontrol )
566
555
{
567
- int val = 0 ;
556
+ int val ;
568
557
struct usb_mixer_elem_info * elem = kcontrol -> private_data ;
569
- struct snd_us16x08_eq_store * store =
570
- ((struct snd_us16x08_eq_store * ) elem -> private_data );
558
+ struct snd_us16x08_eq_store * store = elem -> private_data ;
571
559
int index = ucontrol -> id .index ;
572
560
int b_idx = EQ_STORE_BAND_IDX (elem -> head .id ) - 1 ;
573
561
int p_idx = EQ_STORE_PARAM_IDX (elem -> head .id );
@@ -584,24 +572,23 @@ static int snd_us16x08_eq_put(struct snd_kcontrol *kcontrol,
584
572
{
585
573
struct usb_mixer_elem_info * elem = kcontrol -> private_data ;
586
574
struct snd_usb_audio * chip = elem -> head .mixer -> chip ;
587
- struct snd_us16x08_eq_store * store =
588
- ((struct snd_us16x08_eq_store * ) elem -> private_data );
575
+ struct snd_us16x08_eq_store * store = elem -> private_data ;
589
576
int index = ucontrol -> id .index ;
590
577
char buf [sizeof (eqs_msq )];
591
- int val , err = 0 ;
578
+ int val , err ;
592
579
int b_idx = EQ_STORE_BAND_IDX (elem -> head .id ) - 1 ;
593
580
int p_idx = EQ_STORE_PARAM_IDX (elem -> head .id );
594
581
595
- /* copy URB buffer from EQ template */
596
- memcpy (buf , eqs_msq , sizeof (eqs_msq ));
597
-
598
582
val = ucontrol -> value .integer .value [0 ];
599
583
600
584
/* sanity check */
601
585
if (val < SND_US16X08_KCMIN (kcontrol )
602
586
|| val > SND_US16X08_KCMAX (kcontrol ))
603
587
return - EINVAL ;
604
588
589
+ /* copy URB buffer from EQ template */
590
+ memcpy (buf , eqs_msq , sizeof (eqs_msq ));
591
+
605
592
store -> val [b_idx ][p_idx ][index ] = val ;
606
593
buf [20 ] = store -> val [b_idx ][3 ][index ];
607
594
buf [17 ] = store -> val [b_idx ][2 ][index ];
@@ -713,12 +700,6 @@ static int snd_us16x08_meter_get(struct snd_kcontrol *kcontrol,
713
700
u8 meter_urb [64 ];
714
701
char tmp [sizeof (mix_init_msg2 )] = {0 };
715
702
716
- if (elem ) {
717
- store = (struct snd_us16x08_meter_store * ) elem -> private_data ;
718
- chip = elem -> head .mixer -> chip ;
719
- } else
720
- return 0 ;
721
-
722
703
switch (kcontrol -> private_value ) {
723
704
case 0 :
724
705
snd_us16x08_send_urb (chip , (char * )mix_init_msg1 ,
@@ -983,11 +964,11 @@ static struct snd_kcontrol_new snd_us16x08_meter_ctl = {
983
964
/* setup compressor store and assign default value */
984
965
static struct snd_us16x08_comp_store * snd_us16x08_create_comp_store (void )
985
966
{
986
- int i = 0 ;
987
- struct snd_us16x08_comp_store * tmp =
988
- kmalloc (sizeof (struct snd_us16x08_comp_store ), GFP_KERNEL );
967
+ int i ;
968
+ struct snd_us16x08_comp_store * tmp ;
989
969
990
- if (tmp == NULL )
970
+ tmp = kmalloc (sizeof (* tmp ), GFP_KERNEL );
971
+ if (!tmp )
991
972
return NULL ;
992
973
993
974
for (i = 0 ; i < SND_US16X08_MAX_CHANNELS ; i ++ ) {
@@ -1006,10 +987,10 @@ static struct snd_us16x08_comp_store *snd_us16x08_create_comp_store(void)
1006
987
static struct snd_us16x08_eq_store * snd_us16x08_create_eq_store (void )
1007
988
{
1008
989
int i , b_idx ;
1009
- struct snd_us16x08_eq_store * tmp =
1010
- kmalloc (sizeof (struct snd_us16x08_eq_store ), GFP_KERNEL );
990
+ struct snd_us16x08_eq_store * tmp ;
1011
991
1012
- if (tmp == NULL )
992
+ tmp = kmalloc (sizeof (* tmp ), GFP_KERNEL );
993
+ if (!tmp )
1013
994
return NULL ;
1014
995
1015
996
for (i = 0 ; i < SND_US16X08_MAX_CHANNELS ; i ++ ) {
@@ -1042,15 +1023,14 @@ static struct snd_us16x08_eq_store *snd_us16x08_create_eq_store(void)
1042
1023
1043
1024
static struct snd_us16x08_meter_store * snd_us16x08_create_meter_store (void )
1044
1025
{
1045
- struct snd_us16x08_meter_store * tmp =
1046
- kzalloc (sizeof (struct snd_us16x08_meter_store ), GFP_KERNEL );
1026
+ struct snd_us16x08_meter_store * tmp ;
1047
1027
1028
+ tmp = kzalloc (sizeof (* tmp ), GFP_KERNEL );
1048
1029
if (!tmp )
1049
1030
return NULL ;
1050
1031
tmp -> comp_index = 1 ;
1051
1032
tmp -> comp_active_index = 0 ;
1052
1033
return tmp ;
1053
-
1054
1034
}
1055
1035
1056
1036
/* release elem->private_free as well; called only once for each *_store */
@@ -1067,7 +1047,7 @@ static void elem_private_free(struct snd_kcontrol *kctl)
1067
1047
static int add_new_ctl (struct usb_mixer_interface * mixer ,
1068
1048
const struct snd_kcontrol_new * ncontrol ,
1069
1049
int index , int val_type , int channels ,
1070
- const char * name , const void * opt ,
1050
+ const char * name , void * opt ,
1071
1051
bool do_private_free ,
1072
1052
struct usb_mixer_elem_info * * elem_ret )
1073
1053
{
@@ -1088,7 +1068,7 @@ static int add_new_ctl(struct usb_mixer_interface *mixer,
1088
1068
elem -> head .id = index ;
1089
1069
elem -> val_type = val_type ;
1090
1070
elem -> channels = channels ;
1091
- elem -> private_data = ( void * ) opt ;
1071
+ elem -> private_data = opt ;
1092
1072
1093
1073
kctl = snd_ctl_new1 (ncontrol , elem );
1094
1074
if (!kctl ) {
@@ -1113,10 +1093,8 @@ static int add_new_ctl(struct usb_mixer_interface *mixer,
1113
1093
return 0 ;
1114
1094
}
1115
1095
1116
- static struct snd_us16x08_control_params control_params ;
1117
-
1118
1096
/* table of EQ controls */
1119
- static struct snd_us16x08_control_params eq_controls [] = {
1097
+ static const struct snd_us16x08_control_params eq_controls [] = {
1120
1098
{ /* EQ switch */
1121
1099
.kcontrol_new = & snd_us16x08_eq_switch_ctl ,
1122
1100
.control_id = SND_US16X08_ID_EQENABLE ,
@@ -1197,7 +1175,7 @@ static struct snd_us16x08_control_params eq_controls[] = {
1197
1175
};
1198
1176
1199
1177
/* table of compressor controls */
1200
- static struct snd_us16x08_control_params comp_controls [] = {
1178
+ static const struct snd_us16x08_control_params comp_controls [] = {
1201
1179
{ /* Comp enable */
1202
1180
.kcontrol_new = & snd_us16x08_compswitch_ctl ,
1203
1181
.control_id = SND_US16X08_ID_COMP_SWITCH ,
@@ -1243,7 +1221,7 @@ static struct snd_us16x08_control_params comp_controls[] = {
1243
1221
};
1244
1222
1245
1223
/* table of channel controls */
1246
- static struct snd_us16x08_control_params channel_controls [] = {
1224
+ static const struct snd_us16x08_control_params channel_controls [] = {
1247
1225
{ /* Phase */
1248
1226
.kcontrol_new = & snd_us16x08_ch_boolean_ctl ,
1249
1227
.control_id = SND_US16X08_ID_PHASE ,
@@ -1279,7 +1257,7 @@ static struct snd_us16x08_control_params channel_controls[] = {
1279
1257
};
1280
1258
1281
1259
/* table of master controls */
1282
- static struct snd_us16x08_control_params master_controls [] = {
1260
+ static const struct snd_us16x08_control_params master_controls [] = {
1283
1261
{ /* Master */
1284
1262
.kcontrol_new = & snd_us16x08_master_ctl ,
1285
1263
.control_id = SND_US16X08_ID_FADER ,
@@ -1347,10 +1325,7 @@ int snd_us16x08_controls_create(struct usb_mixer_interface *mixer)
1347
1325
return - ENOMEM ;
1348
1326
1349
1327
/* add master controls */
1350
- for (i = 0 ;
1351
- i < sizeof (master_controls )
1352
- / sizeof (control_params );
1353
- i ++ ) {
1328
+ for (i = 0 ; i < ARRAY_SIZE (master_controls ); i ++ ) {
1354
1329
1355
1330
err = add_new_ctl (mixer ,
1356
1331
master_controls [i ].kcontrol_new ,
@@ -1368,10 +1343,7 @@ int snd_us16x08_controls_create(struct usb_mixer_interface *mixer)
1368
1343
}
1369
1344
1370
1345
/* add channel controls */
1371
- for (i = 0 ;
1372
- i < sizeof (channel_controls )
1373
- / sizeof (control_params );
1374
- i ++ ) {
1346
+ for (i = 0 ; i < ARRAY_SIZE (channel_controls ); i ++ ) {
1375
1347
1376
1348
err = add_new_ctl (mixer ,
1377
1349
channel_controls [i ].kcontrol_new ,
@@ -1396,8 +1368,7 @@ int snd_us16x08_controls_create(struct usb_mixer_interface *mixer)
1396
1368
return - ENOMEM ;
1397
1369
1398
1370
/* add EQ controls */
1399
- for (i = 0 ; i < sizeof (eq_controls ) /
1400
- sizeof (control_params ); i ++ ) {
1371
+ for (i = 0 ; i < ARRAY_SIZE (eq_controls ); i ++ ) {
1401
1372
1402
1373
err = add_new_ctl (mixer ,
1403
1374
eq_controls [i ].kcontrol_new ,
@@ -1413,10 +1384,7 @@ int snd_us16x08_controls_create(struct usb_mixer_interface *mixer)
1413
1384
}
1414
1385
1415
1386
/* add compressor controls */
1416
- for (i = 0 ;
1417
- i < sizeof (comp_controls )
1418
- / sizeof (control_params );
1419
- i ++ ) {
1387
+ for (i = 0 ; i < ARRAY_SIZE (comp_controls ); i ++ ) {
1420
1388
1421
1389
err = add_new_ctl (mixer ,
1422
1390
comp_controls [i ].kcontrol_new ,
0 commit comments