aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci/ca0106
diff options
context:
space:
mode:
authorTrent Piepho <xyzzy@speakeasy.org>2007-07-24 06:10:34 -0400
committerJaroslav Kysela <perex@perex.cz>2007-10-16 09:57:56 -0400
commitfca7f38892fa713d5221e26fd3ee57817b4bc031 (patch)
tree935074b8b1c3c171b5396314545c47abaa66032f /sound/pci/ca0106
parentb18cd538a92247307247a53f57c477edbcedbb79 (diff)
[ALSA] ca0106: replaced control add sequences with macro
Turn a rather long lined for loop that is duplicated multiple times into a macro. Signed-off-by: Trent Piepho <xyzzy@speakeasy.org> Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Jaroslav Kysela <perex@suse.cz>
Diffstat (limited to 'sound/pci/ca0106')
-rw-r--r--sound/pci/ca0106/ca0106_mixer.c33
1 files changed, 15 insertions, 18 deletions
diff --git a/sound/pci/ca0106/ca0106_mixer.c b/sound/pci/ca0106/ca0106_mixer.c
index 7fbfe17438b4..18a0525a6b5c 100644
--- a/sound/pci/ca0106/ca0106_mixer.c
+++ b/sound/pci/ca0106/ca0106_mixer.c
@@ -643,9 +643,19 @@ static int __devinit rename_ctl(struct snd_card *card, const char *src, const ch
643 return -ENOENT; 643 return -ENOENT;
644} 644}
645 645
646#define ADD_CTLS(emu, ctls) \
647 do { \
648 int i, err; \
649 for (i = 0; i < ARRAY_SIZE(ctls); i++) { \
650 err = snd_ctl_add(card, snd_ctl_new1(&ctls[i], emu)); \
651 if (err < 0) \
652 return err; \
653 } \
654 } while (0)
655
646int __devinit snd_ca0106_mixer(struct snd_ca0106 *emu) 656int __devinit snd_ca0106_mixer(struct snd_ca0106 *emu)
647{ 657{
648 int i, err; 658 int err;
649 struct snd_card *card = emu->card; 659 struct snd_card *card = emu->card;
650 char **c; 660 char **c;
651 static char *ca0106_remove_ctls[] = { 661 static char *ca0106_remove_ctls[] = {
@@ -692,17 +702,9 @@ int __devinit snd_ca0106_mixer(struct snd_ca0106 *emu)
692 rename_ctl(card, c[0], c[1]); 702 rename_ctl(card, c[0], c[1]);
693#endif 703#endif
694 704
695 for (i = 0; i < ARRAY_SIZE(snd_ca0106_volume_ctls); i++) { 705 ADD_CTLS(emu, snd_ca0106_volume_ctls);
696 err = snd_ctl_add(card, snd_ctl_new1(&snd_ca0106_volume_ctls[i], emu));
697 if (err < 0)
698 return err;
699 }
700 if (emu->details->i2c_adc == 1) { 706 if (emu->details->i2c_adc == 1) {
701 for (i = 0; i < ARRAY_SIZE(snd_ca0106_volume_i2c_adc_ctls); i++) { 707 ADD_CTLS(emu, snd_ca0106_volume_i2c_adc_ctls);
702 err = snd_ctl_add(card, snd_ctl_new1(&snd_ca0106_volume_i2c_adc_ctls[i], emu));
703 if (err < 0)
704 return err;
705 }
706 if (emu->details->gpio_type == 1) 708 if (emu->details->gpio_type == 1)
707 err = snd_ctl_add(card, snd_ctl_new1(&snd_ca0106_capture_mic_line_in, emu)); 709 err = snd_ctl_add(card, snd_ctl_new1(&snd_ca0106_capture_mic_line_in, emu));
708 else /* gpio_type == 2 */ 710 else /* gpio_type == 2 */
@@ -710,13 +712,8 @@ int __devinit snd_ca0106_mixer(struct snd_ca0106 *emu)
710 if (err < 0) 712 if (err < 0)
711 return err; 713 return err;
712 } 714 }
713 if (emu->details->spi_dac == 1) { 715 if (emu->details->spi_dac == 1)
714 for (i = 0; i < ARRAY_SIZE(snd_ca0106_volume_spi_dac_ctls); i++) { 716 ADD_CTLS(emu, snd_ca0106_volume_spi_dac_ctls);
715 err = snd_ctl_add(card, snd_ctl_new1(&snd_ca0106_volume_spi_dac_ctls[i], emu));
716 if (err < 0)
717 return err;
718 }
719 }
720 return 0; 717 return 0;
721} 718}
722 719