# HG changeset patch # User Trent Piepho # Date 1185229288 25200 # Node ID 677282fd6bcc15373480eefb52b763b363d940ee # Parent 87a07ac27d0cd5f7ce391f3f52229b6516efb3bc 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 diff -r 87a07ac27d0c -r 677282fd6bcc pci/ca0106/ca0106_mixer.c --- a/pci/ca0106/ca0106_mixer.c Mon Jul 23 15:11:00 2007 -0700 +++ b/pci/ca0106/ca0106_mixer.c Mon Jul 23 15:21:28 2007 -0700 @@ -643,6 +643,13 @@ static int __devinit rename_ctl(struct s return -ENOENT; } +#define ADD_CTLS(ctls) \ + for (i = 0; i < ARRAY_SIZE(ctls); i++) { \ + err = snd_ctl_add(card, snd_ctl_new1(&ctls[i], emu)); \ + if (err < 0) \ + return err; \ + } \ + int __devinit snd_ca0106_mixer(struct snd_ca0106 *emu) { int i, err; @@ -692,17 +699,9 @@ int __devinit snd_ca0106_mixer(struct sn 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(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(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 +709,8 @@ int __devinit snd_ca0106_mixer(struct sn 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(snd_ca0106_volume_spi_dac_ctls); return 0; }