diff options
author | Takashi Iwai <tiwai@suse.de> | 2017-02-22 02:37:41 -0500 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2017-02-22 09:07:20 -0500 |
commit | 7086b7b3d101e0e6fca2bf7ca2f14483fc881837 (patch) | |
tree | 12ed6cdfeb8af27eb229d4ca62bab3567e1cc68e /sound/usb | |
parent | e2810d76c5f3b0152fa0f7c40170e123b33e058c (diff) |
ALSA: usb-audio: Tidy up mixer_us16x08.c
A few more cleanups and improvements that have been overlooked:
- Use ARRAY_SIZE() macro appropriately
- Code shuffling for minor optimization
- Omit superfluous variable initializations
- Get rid of superfluous NULL checks
- Add const to snd_us16x08_control_params definitions
No functional changes.
Reviewed-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/usb')
-rw-r--r-- | sound/usb/mixer_us16x08.c | 132 |
1 files changed, 50 insertions, 82 deletions
diff --git a/sound/usb/mixer_us16x08.c b/sound/usb/mixer_us16x08.c index f7289541fbce..dc48eedea92e 100644 --- a/sound/usb/mixer_us16x08.c +++ b/sound/usb/mixer_us16x08.c | |||
@@ -176,15 +176,9 @@ static int snd_us16x08_recv_urb(struct snd_usb_audio *chip, | |||
176 | */ | 176 | */ |
177 | static int snd_us16x08_send_urb(struct snd_usb_audio *chip, char *buf, int size) | 177 | static int snd_us16x08_send_urb(struct snd_usb_audio *chip, char *buf, int size) |
178 | { | 178 | { |
179 | int err = 0; | 179 | return snd_usb_ctl_msg(chip->dev, usb_sndctrlpipe(chip->dev, 0), |
180 | |||
181 | if (chip) { | ||
182 | err = snd_usb_ctl_msg(chip->dev, usb_sndctrlpipe(chip->dev, 0), | ||
183 | SND_US16X08_URB_REQUEST, SND_US16X08_URB_REQUESTTYPE, | 180 | SND_US16X08_URB_REQUEST, SND_US16X08_URB_REQUESTTYPE, |
184 | 0, 0, buf, size); | 181 | 0, 0, buf, size); |
185 | } | ||
186 | |||
187 | return err; | ||
188 | } | 182 | } |
189 | 183 | ||
190 | static int snd_us16x08_route_info(struct snd_kcontrol *kcontrol, | 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 | struct snd_usb_audio *chip = elem->head.mixer->chip; | 206 | struct snd_usb_audio *chip = elem->head.mixer->chip; |
213 | int index = ucontrol->id.index; | 207 | int index = ucontrol->id.index; |
214 | char buf[sizeof(route_msg)]; | 208 | char buf[sizeof(route_msg)]; |
215 | int val, val_org, err = 0; | 209 | int val, val_org, err; |
216 | |||
217 | /* prepare the message buffer from template */ | ||
218 | memcpy(buf, route_msg, sizeof(route_msg)); | ||
219 | 210 | ||
220 | /* get the new value (no bias for routes) */ | 211 | /* get the new value (no bias for routes) */ |
221 | val = ucontrol->value.enumerated.item[0]; | 212 | val = ucontrol->value.enumerated.item[0]; |
@@ -224,6 +215,9 @@ static int snd_us16x08_route_put(struct snd_kcontrol *kcontrol, | |||
224 | if (val < 0 || val > 9) | 215 | if (val < 0 || val > 9) |
225 | return -EINVAL; | 216 | return -EINVAL; |
226 | 217 | ||
218 | /* prepare the message buffer from template */ | ||
219 | memcpy(buf, route_msg, sizeof(route_msg)); | ||
220 | |||
227 | if (val < 2) { | 221 | if (val < 2) { |
228 | /* input comes from a master channel */ | 222 | /* input comes from a master channel */ |
229 | val_org = val; | 223 | val_org = val; |
@@ -279,12 +273,9 @@ static int snd_us16x08_master_put(struct snd_kcontrol *kcontrol, | |||
279 | struct usb_mixer_elem_info *elem = kcontrol->private_data; | 273 | struct usb_mixer_elem_info *elem = kcontrol->private_data; |
280 | struct snd_usb_audio *chip = elem->head.mixer->chip; | 274 | struct snd_usb_audio *chip = elem->head.mixer->chip; |
281 | char buf[sizeof(mix_msg_out)]; | 275 | char buf[sizeof(mix_msg_out)]; |
282 | int val, err = 0; | 276 | int val, err; |
283 | int index = ucontrol->id.index; | 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 | /* new control value incl. bias*/ | 279 | /* new control value incl. bias*/ |
289 | val = ucontrol->value.integer.value[0]; | 280 | val = ucontrol->value.integer.value[0]; |
290 | 281 | ||
@@ -293,6 +284,9 @@ static int snd_us16x08_master_put(struct snd_kcontrol *kcontrol, | |||
293 | || val > SND_US16X08_KCMAX(kcontrol)) | 284 | || val > SND_US16X08_KCMAX(kcontrol)) |
294 | return -EINVAL; | 285 | return -EINVAL; |
295 | 286 | ||
287 | /* prepare the message buffer from template */ | ||
288 | memcpy(buf, mix_msg_out, sizeof(mix_msg_out)); | ||
289 | |||
296 | buf[8] = val - SND_US16X08_KCBIAS(kcontrol); | 290 | buf[8] = val - SND_US16X08_KCBIAS(kcontrol); |
297 | buf[6] = elem->head.id; | 291 | buf[6] = elem->head.id; |
298 | 292 | ||
@@ -392,9 +386,6 @@ static int snd_us16x08_channel_put(struct snd_kcontrol *kcontrol, | |||
392 | int val, err; | 386 | int val, err; |
393 | int index = ucontrol->id.index; | 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 | val = ucontrol->value.integer.value[0]; | 389 | val = ucontrol->value.integer.value[0]; |
399 | 390 | ||
400 | /* sanity check */ | 391 | /* sanity check */ |
@@ -402,6 +393,9 @@ static int snd_us16x08_channel_put(struct snd_kcontrol *kcontrol, | |||
402 | || val > SND_US16X08_KCMAX(kcontrol)) | 393 | || val > SND_US16X08_KCMAX(kcontrol)) |
403 | return -EINVAL; | 394 | return -EINVAL; |
404 | 395 | ||
396 | /* prepare URB message from template */ | ||
397 | memcpy(buf, mix_msg_in, sizeof(mix_msg_in)); | ||
398 | |||
405 | /* add the bias to the new value */ | 399 | /* add the bias to the new value */ |
406 | buf[8] = val - SND_US16X08_KCBIAS(kcontrol); | 400 | buf[8] = val - SND_US16X08_KCBIAS(kcontrol); |
407 | buf[6] = elem->head.id; | 401 | buf[6] = elem->head.id; |
@@ -434,8 +428,7 @@ static int snd_us16x08_comp_get(struct snd_kcontrol *kcontrol, | |||
434 | struct snd_ctl_elem_value *ucontrol) | 428 | struct snd_ctl_elem_value *ucontrol) |
435 | { | 429 | { |
436 | struct usb_mixer_elem_info *elem = kcontrol->private_data; | 430 | struct usb_mixer_elem_info *elem = kcontrol->private_data; |
437 | struct snd_us16x08_comp_store *store = | 431 | struct snd_us16x08_comp_store *store = elem->private_data; |
438 | ((struct snd_us16x08_comp_store *) elem->private_data); | ||
439 | int index = ucontrol->id.index; | 432 | int index = ucontrol->id.index; |
440 | int val_idx = COMP_STORE_IDX(elem->head.id); | 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 | struct usb_mixer_elem_info *elem = kcontrol->private_data; | 443 | struct usb_mixer_elem_info *elem = kcontrol->private_data; |
451 | struct snd_usb_audio *chip = elem->head.mixer->chip; | 444 | struct snd_usb_audio *chip = elem->head.mixer->chip; |
452 | struct snd_us16x08_comp_store *store = | 445 | struct snd_us16x08_comp_store *store = elem->private_data; |
453 | ((struct snd_us16x08_comp_store *) elem->private_data); | ||
454 | int index = ucontrol->id.index; | 446 | int index = ucontrol->id.index; |
455 | char buf[sizeof(comp_msg)]; | 447 | char buf[sizeof(comp_msg)]; |
456 | int val_idx, val; | 448 | int val_idx, val; |
457 | int err = 0; | 449 | int err; |
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; | ||
464 | 450 | ||
465 | val = ucontrol->value.integer.value[0]; | 451 | val = ucontrol->value.integer.value[0]; |
466 | 452 | ||
@@ -469,8 +455,14 @@ static int snd_us16x08_comp_put(struct snd_kcontrol *kcontrol, | |||
469 | || val > SND_US16X08_KCMAX(kcontrol)) | 455 | || val > SND_US16X08_KCMAX(kcontrol)) |
470 | return -EINVAL; | 456 | return -EINVAL; |
471 | 457 | ||
458 | /* new control value incl. bias*/ | ||
459 | val_idx = elem->head.id - SND_US16X08_ID_COMP_BASE; | ||
460 | |||
472 | store->val[val_idx][index] = ucontrol->value.integer.value[0]; | 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 | /* place comp values in message buffer watch bias! */ | 466 | /* place comp values in message buffer watch bias! */ |
475 | buf[8] = store->val[ | 467 | buf[8] = store->val[ |
476 | COMP_STORE_IDX(SND_US16X08_ID_COMP_THRESHOLD)][index] | 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 | static int snd_us16x08_eqswitch_get(struct snd_kcontrol *kcontrol, | 494 | static int snd_us16x08_eqswitch_get(struct snd_kcontrol *kcontrol, |
503 | struct snd_ctl_elem_value *ucontrol) | 495 | struct snd_ctl_elem_value *ucontrol) |
504 | { | 496 | { |
505 | int val = 0; | 497 | int val; |
506 | struct usb_mixer_elem_info *elem = kcontrol->private_data; | 498 | struct usb_mixer_elem_info *elem = kcontrol->private_data; |
507 | struct snd_us16x08_eq_store *store = | 499 | struct snd_us16x08_eq_store *store = elem->private_data; |
508 | ((struct snd_us16x08_eq_store *) elem->private_data); | ||
509 | int index = ucontrol->id.index; | 500 | int index = ucontrol->id.index; |
510 | 501 | ||
511 | /* get low switch from cache is enough, cause all bands are together */ | 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 | struct usb_mixer_elem_info *elem = kcontrol->private_data; | 513 | struct usb_mixer_elem_info *elem = kcontrol->private_data; |
523 | struct snd_usb_audio *chip = elem->head.mixer->chip; | 514 | struct snd_usb_audio *chip = elem->head.mixer->chip; |
524 | struct snd_us16x08_eq_store *store = | 515 | struct snd_us16x08_eq_store *store = elem->private_data; |
525 | ((struct snd_us16x08_eq_store *) elem->private_data); | ||
526 | int index = ucontrol->id.index; | 516 | int index = ucontrol->id.index; |
527 | |||
528 | char buf[sizeof(eqs_msq)]; | 517 | char buf[sizeof(eqs_msq)]; |
529 | int val, err = 0; | 518 | int val, err = 0; |
530 | int b_idx; | 519 | int b_idx; |
@@ -564,10 +553,9 @@ static int snd_us16x08_eqswitch_put(struct snd_kcontrol *kcontrol, | |||
564 | static int snd_us16x08_eq_get(struct snd_kcontrol *kcontrol, | 553 | static int snd_us16x08_eq_get(struct snd_kcontrol *kcontrol, |
565 | struct snd_ctl_elem_value *ucontrol) | 554 | struct snd_ctl_elem_value *ucontrol) |
566 | { | 555 | { |
567 | int val = 0; | 556 | int val; |
568 | struct usb_mixer_elem_info *elem = kcontrol->private_data; | 557 | struct usb_mixer_elem_info *elem = kcontrol->private_data; |
569 | struct snd_us16x08_eq_store *store = | 558 | struct snd_us16x08_eq_store *store = elem->private_data; |
570 | ((struct snd_us16x08_eq_store *) elem->private_data); | ||
571 | int index = ucontrol->id.index; | 559 | int index = ucontrol->id.index; |
572 | int b_idx = EQ_STORE_BAND_IDX(elem->head.id) - 1; | 560 | int b_idx = EQ_STORE_BAND_IDX(elem->head.id) - 1; |
573 | int p_idx = EQ_STORE_PARAM_IDX(elem->head.id); | 561 | int p_idx = EQ_STORE_PARAM_IDX(elem->head.id); |
@@ -584,17 +572,13 @@ static int snd_us16x08_eq_put(struct snd_kcontrol *kcontrol, | |||
584 | { | 572 | { |
585 | struct usb_mixer_elem_info *elem = kcontrol->private_data; | 573 | struct usb_mixer_elem_info *elem = kcontrol->private_data; |
586 | struct snd_usb_audio *chip = elem->head.mixer->chip; | 574 | struct snd_usb_audio *chip = elem->head.mixer->chip; |
587 | struct snd_us16x08_eq_store *store = | 575 | struct snd_us16x08_eq_store *store = elem->private_data; |
588 | ((struct snd_us16x08_eq_store *) elem->private_data); | ||
589 | int index = ucontrol->id.index; | 576 | int index = ucontrol->id.index; |
590 | char buf[sizeof(eqs_msq)]; | 577 | char buf[sizeof(eqs_msq)]; |
591 | int val, err = 0; | 578 | int val, err; |
592 | int b_idx = EQ_STORE_BAND_IDX(elem->head.id) - 1; | 579 | int b_idx = EQ_STORE_BAND_IDX(elem->head.id) - 1; |
593 | int p_idx = EQ_STORE_PARAM_IDX(elem->head.id); | 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 | val = ucontrol->value.integer.value[0]; | 582 | val = ucontrol->value.integer.value[0]; |
599 | 583 | ||
600 | /* sanity check */ | 584 | /* sanity check */ |
@@ -602,6 +586,9 @@ static int snd_us16x08_eq_put(struct snd_kcontrol *kcontrol, | |||
602 | || val > SND_US16X08_KCMAX(kcontrol)) | 586 | || val > SND_US16X08_KCMAX(kcontrol)) |
603 | return -EINVAL; | 587 | return -EINVAL; |
604 | 588 | ||
589 | /* copy URB buffer from EQ template */ | ||
590 | memcpy(buf, eqs_msq, sizeof(eqs_msq)); | ||
591 | |||
605 | store->val[b_idx][p_idx][index] = val; | 592 | store->val[b_idx][p_idx][index] = val; |
606 | buf[20] = store->val[b_idx][3][index]; | 593 | buf[20] = store->val[b_idx][3][index]; |
607 | buf[17] = store->val[b_idx][2][index]; | 594 | buf[17] = store->val[b_idx][2][index]; |
@@ -713,12 +700,6 @@ static int snd_us16x08_meter_get(struct snd_kcontrol *kcontrol, | |||
713 | u8 meter_urb[64]; | 700 | u8 meter_urb[64]; |
714 | char tmp[sizeof(mix_init_msg2)] = {0}; | 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 | switch (kcontrol->private_value) { | 703 | switch (kcontrol->private_value) { |
723 | case 0: | 704 | case 0: |
724 | snd_us16x08_send_urb(chip, (char *)mix_init_msg1, | 705 | snd_us16x08_send_urb(chip, (char *)mix_init_msg1, |
@@ -983,11 +964,11 @@ static struct snd_kcontrol_new snd_us16x08_meter_ctl = { | |||
983 | /* setup compressor store and assign default value */ | 964 | /* setup compressor store and assign default value */ |
984 | static struct snd_us16x08_comp_store *snd_us16x08_create_comp_store(void) | 965 | static struct snd_us16x08_comp_store *snd_us16x08_create_comp_store(void) |
985 | { | 966 | { |
986 | int i = 0; | 967 | int i; |
987 | struct snd_us16x08_comp_store *tmp = | 968 | struct snd_us16x08_comp_store *tmp; |
988 | kmalloc(sizeof(struct snd_us16x08_comp_store), GFP_KERNEL); | ||
989 | 969 | ||
990 | if (tmp == NULL) | 970 | tmp = kmalloc(sizeof(*tmp), GFP_KERNEL); |
971 | if (!tmp) | ||
991 | return NULL; | 972 | return NULL; |
992 | 973 | ||
993 | for (i = 0; i < SND_US16X08_MAX_CHANNELS; i++) { | 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 | static struct snd_us16x08_eq_store *snd_us16x08_create_eq_store(void) | 987 | static struct snd_us16x08_eq_store *snd_us16x08_create_eq_store(void) |
1007 | { | 988 | { |
1008 | int i, b_idx; | 989 | int i, b_idx; |
1009 | struct snd_us16x08_eq_store *tmp = | 990 | struct snd_us16x08_eq_store *tmp; |
1010 | kmalloc(sizeof(struct snd_us16x08_eq_store), GFP_KERNEL); | ||
1011 | 991 | ||
1012 | if (tmp == NULL) | 992 | tmp = kmalloc(sizeof(*tmp), GFP_KERNEL); |
993 | if (!tmp) | ||
1013 | return NULL; | 994 | return NULL; |
1014 | 995 | ||
1015 | for (i = 0; i < SND_US16X08_MAX_CHANNELS; i++) { | 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 | static struct snd_us16x08_meter_store *snd_us16x08_create_meter_store(void) | 1024 | static struct snd_us16x08_meter_store *snd_us16x08_create_meter_store(void) |
1044 | { | 1025 | { |
1045 | struct snd_us16x08_meter_store *tmp = | 1026 | struct snd_us16x08_meter_store *tmp; |
1046 | kzalloc(sizeof(struct snd_us16x08_meter_store), GFP_KERNEL); | ||
1047 | 1027 | ||
1028 | tmp = kzalloc(sizeof(*tmp), GFP_KERNEL); | ||
1048 | if (!tmp) | 1029 | if (!tmp) |
1049 | return NULL; | 1030 | return NULL; |
1050 | tmp->comp_index = 1; | 1031 | tmp->comp_index = 1; |
1051 | tmp->comp_active_index = 0; | 1032 | tmp->comp_active_index = 0; |
1052 | return tmp; | 1033 | return tmp; |
1053 | |||
1054 | } | 1034 | } |
1055 | 1035 | ||
1056 | /* release elem->private_free as well; called only once for each *_store */ | 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 | static int add_new_ctl(struct usb_mixer_interface *mixer, | 1047 | static int add_new_ctl(struct usb_mixer_interface *mixer, |
1068 | const struct snd_kcontrol_new *ncontrol, | 1048 | const struct snd_kcontrol_new *ncontrol, |
1069 | int index, int val_type, int channels, | 1049 | int index, int val_type, int channels, |
1070 | const char *name, const void *opt, | 1050 | const char *name, void *opt, |
1071 | bool do_private_free, | 1051 | bool do_private_free, |
1072 | struct usb_mixer_elem_info **elem_ret) | 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 | elem->head.id = index; | 1068 | elem->head.id = index; |
1089 | elem->val_type = val_type; | 1069 | elem->val_type = val_type; |
1090 | elem->channels = channels; | 1070 | elem->channels = channels; |
1091 | elem->private_data = (void *) opt; | 1071 | elem->private_data = opt; |
1092 | 1072 | ||
1093 | kctl = snd_ctl_new1(ncontrol, elem); | 1073 | kctl = snd_ctl_new1(ncontrol, elem); |
1094 | if (!kctl) { | 1074 | if (!kctl) { |
@@ -1113,10 +1093,8 @@ static int add_new_ctl(struct usb_mixer_interface *mixer, | |||
1113 | return 0; | 1093 | return 0; |
1114 | } | 1094 | } |
1115 | 1095 | ||
1116 | static struct snd_us16x08_control_params control_params; | ||
1117 | |||
1118 | /* table of EQ controls */ | 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 | { /* EQ switch */ | 1098 | { /* EQ switch */ |
1121 | .kcontrol_new = &snd_us16x08_eq_switch_ctl, | 1099 | .kcontrol_new = &snd_us16x08_eq_switch_ctl, |
1122 | .control_id = SND_US16X08_ID_EQENABLE, | 1100 | .control_id = SND_US16X08_ID_EQENABLE, |
@@ -1197,7 +1175,7 @@ static struct snd_us16x08_control_params eq_controls[] = { | |||
1197 | }; | 1175 | }; |
1198 | 1176 | ||
1199 | /* table of compressor controls */ | 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 | { /* Comp enable */ | 1179 | { /* Comp enable */ |
1202 | .kcontrol_new = &snd_us16x08_compswitch_ctl, | 1180 | .kcontrol_new = &snd_us16x08_compswitch_ctl, |
1203 | .control_id = SND_US16X08_ID_COMP_SWITCH, | 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 | /* table of channel controls */ | 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 | { /* Phase */ | 1225 | { /* Phase */ |
1248 | .kcontrol_new = &snd_us16x08_ch_boolean_ctl, | 1226 | .kcontrol_new = &snd_us16x08_ch_boolean_ctl, |
1249 | .control_id = SND_US16X08_ID_PHASE, | 1227 | .control_id = SND_US16X08_ID_PHASE, |
@@ -1279,7 +1257,7 @@ static struct snd_us16x08_control_params channel_controls[] = { | |||
1279 | }; | 1257 | }; |
1280 | 1258 | ||
1281 | /* table of master controls */ | 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 | { /* Master */ | 1261 | { /* Master */ |
1284 | .kcontrol_new = &snd_us16x08_master_ctl, | 1262 | .kcontrol_new = &snd_us16x08_master_ctl, |
1285 | .control_id = SND_US16X08_ID_FADER, | 1263 | .control_id = SND_US16X08_ID_FADER, |
@@ -1347,10 +1325,7 @@ int snd_us16x08_controls_create(struct usb_mixer_interface *mixer) | |||
1347 | return -ENOMEM; | 1325 | return -ENOMEM; |
1348 | 1326 | ||
1349 | /* add master controls */ | 1327 | /* add master controls */ |
1350 | for (i = 0; | 1328 | for (i = 0; i < ARRAY_SIZE(master_controls); i++) { |
1351 | i < sizeof(master_controls) | ||
1352 | / sizeof(control_params); | ||
1353 | i++) { | ||
1354 | 1329 | ||
1355 | err = add_new_ctl(mixer, | 1330 | err = add_new_ctl(mixer, |
1356 | master_controls[i].kcontrol_new, | 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 | /* add channel controls */ | 1345 | /* add channel controls */ |
1371 | for (i = 0; | 1346 | for (i = 0; i < ARRAY_SIZE(channel_controls); i++) { |
1372 | i < sizeof(channel_controls) | ||
1373 | / sizeof(control_params); | ||
1374 | i++) { | ||
1375 | 1347 | ||
1376 | err = add_new_ctl(mixer, | 1348 | err = add_new_ctl(mixer, |
1377 | channel_controls[i].kcontrol_new, | 1349 | channel_controls[i].kcontrol_new, |
@@ -1396,8 +1368,7 @@ int snd_us16x08_controls_create(struct usb_mixer_interface *mixer) | |||
1396 | return -ENOMEM; | 1368 | return -ENOMEM; |
1397 | 1369 | ||
1398 | /* add EQ controls */ | 1370 | /* add EQ controls */ |
1399 | for (i = 0; i < sizeof(eq_controls) / | 1371 | for (i = 0; i < ARRAY_SIZE(eq_controls); i++) { |
1400 | sizeof(control_params); i++) { | ||
1401 | 1372 | ||
1402 | err = add_new_ctl(mixer, | 1373 | err = add_new_ctl(mixer, |
1403 | eq_controls[i].kcontrol_new, | 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 | /* add compressor controls */ | 1386 | /* add compressor controls */ |
1416 | for (i = 0; | 1387 | for (i = 0; i < ARRAY_SIZE(comp_controls); i++) { |
1417 | i < sizeof(comp_controls) | ||
1418 | / sizeof(control_params); | ||
1419 | i++) { | ||
1420 | 1388 | ||
1421 | err = add_new_ctl(mixer, | 1389 | err = add_new_ctl(mixer, |
1422 | comp_controls[i].kcontrol_new, | 1390 | comp_controls[i].kcontrol_new, |