Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=fca7f38892fa713d5221e26fd3ee57817b4bc031
Commit:     fca7f38892fa713d5221e26fd3ee57817b4bc031
Parent:     b18cd538a92247307247a53f57c477edbcedbb79
Author:     Trent Piepho <[EMAIL PROTECTED]>
AuthorDate: Tue Jul 24 12:10:34 2007 +0200
Committer:  Jaroslav Kysela <[EMAIL PROTECTED]>
CommitDate: Tue Oct 16 15:57:56 2007 +0200

    [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 <[EMAIL PROTECTED]>
    Signed-off-by: Takashi Iwai <[EMAIL PROTECTED]>
    Signed-off-by: Jaroslav Kysela <[EMAIL PROTECTED]>
---
 sound/pci/ca0106/ca0106_mixer.c |   33 +++++++++++++++------------------
 1 files changed, 15 insertions(+), 18 deletions(-)

diff --git a/sound/pci/ca0106/ca0106_mixer.c b/sound/pci/ca0106/ca0106_mixer.c
index 7fbfe17..18a0525 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
        return -ENOENT;
 }
 
+#define ADD_CTLS(emu, ctls)                                            \
+       do {                                                            \
+               int i, err;                                             \
+               for (i = 0; i < ARRAY_SIZE(ctls); i++) {                \
+                       err = snd_ctl_add(card, snd_ctl_new1(&ctls[i], emu)); \
+                       if (err < 0)                                    \
+                               return err;                             \
+               }                                                       \
+       } while (0)
+
 int __devinit snd_ca0106_mixer(struct snd_ca0106 *emu)
 {
-       int i, err;
+       int err;
         struct snd_card *card = emu->card;
        char **c;
        static char *ca0106_remove_ctls[] = {
@@ -692,17 +702,9 @@ int __devinit snd_ca0106_mixer(struct snd_ca0106 *emu)
                rename_ctl(card, c[0], c[1]);
 #endif
 
-       for (i = 0; i < ARRAY_SIZE(snd_ca0106_volume_ctls); i++) {
-               err = snd_ctl_add(card, 
snd_ctl_new1(&snd_ca0106_volume_ctls[i], emu));
-               if (err < 0)
-                       return err;
-       }
+       ADD_CTLS(emu, snd_ca0106_volume_ctls);
        if (emu->details->i2c_adc == 1) {
-               for (i = 0; i < ARRAY_SIZE(snd_ca0106_volume_i2c_adc_ctls); 
i++) {
-                       err = snd_ctl_add(card, 
snd_ctl_new1(&snd_ca0106_volume_i2c_adc_ctls[i], emu));
-                       if (err < 0)
-                               return err;
-               }
+               ADD_CTLS(emu, snd_ca0106_volume_i2c_adc_ctls);
                if (emu->details->gpio_type == 1)
                        err = snd_ctl_add(card, 
snd_ctl_new1(&snd_ca0106_capture_mic_line_in, emu));
                else  /* gpio_type == 2 */
@@ -710,13 +712,8 @@ int __devinit snd_ca0106_mixer(struct snd_ca0106 *emu)
                if (err < 0)
                        return err;
        }
-       if (emu->details->spi_dac == 1) {
-               for (i = 0; i < ARRAY_SIZE(snd_ca0106_volume_spi_dac_ctls); 
i++) {
-                       err = snd_ctl_add(card, 
snd_ctl_new1(&snd_ca0106_volume_spi_dac_ctls[i], emu));
-                       if (err < 0)
-                               return err;
-               }
-       }
+       if (emu->details->spi_dac == 1)
+               ADD_CTLS(emu, snd_ca0106_volume_spi_dac_ctls);
         return 0;
 }
 
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to