mirror of
https://github.com/followmsi/android_kernel_google_msm.git
synced 2024-09-22 04:32:41 +00:00
[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>
This commit is contained in:
parent
b18cd538a9
commit
fca7f38892
1 changed files with 15 additions and 18 deletions
|
@ -643,9 +643,19 @@ static int __devinit rename_ctl(struct snd_card *card, const char *src, const ch
|
||||||
return -ENOENT;
|
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 __devinit snd_ca0106_mixer(struct snd_ca0106 *emu)
|
||||||
{
|
{
|
||||||
int i, err;
|
int err;
|
||||||
struct snd_card *card = emu->card;
|
struct snd_card *card = emu->card;
|
||||||
char **c;
|
char **c;
|
||||||
static char *ca0106_remove_ctls[] = {
|
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]);
|
rename_ctl(card, c[0], c[1]);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_SIZE(snd_ca0106_volume_ctls); i++) {
|
ADD_CTLS(emu, snd_ca0106_volume_ctls);
|
||||||
err = snd_ctl_add(card, snd_ctl_new1(&snd_ca0106_volume_ctls[i], emu));
|
|
||||||
if (err < 0)
|
|
||||||
return err;
|
|
||||||
}
|
|
||||||
if (emu->details->i2c_adc == 1) {
|
if (emu->details->i2c_adc == 1) {
|
||||||
for (i = 0; i < ARRAY_SIZE(snd_ca0106_volume_i2c_adc_ctls); i++) {
|
ADD_CTLS(emu, snd_ca0106_volume_i2c_adc_ctls);
|
||||||
err = snd_ctl_add(card, snd_ctl_new1(&snd_ca0106_volume_i2c_adc_ctls[i], emu));
|
|
||||||
if (err < 0)
|
|
||||||
return err;
|
|
||||||
}
|
|
||||||
if (emu->details->gpio_type == 1)
|
if (emu->details->gpio_type == 1)
|
||||||
err = snd_ctl_add(card, snd_ctl_new1(&snd_ca0106_capture_mic_line_in, emu));
|
err = snd_ctl_add(card, snd_ctl_new1(&snd_ca0106_capture_mic_line_in, emu));
|
||||||
else /* gpio_type == 2 */
|
else /* gpio_type == 2 */
|
||||||
|
@ -710,13 +712,8 @@ int __devinit snd_ca0106_mixer(struct snd_ca0106 *emu)
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
if (emu->details->spi_dac == 1) {
|
if (emu->details->spi_dac == 1)
|
||||||
for (i = 0; i < ARRAY_SIZE(snd_ca0106_volume_spi_dac_ctls); i++) {
|
ADD_CTLS(emu, snd_ca0106_volume_spi_dac_ctls);
|
||||||
err = snd_ctl_add(card, snd_ctl_new1(&snd_ca0106_volume_spi_dac_ctls[i], emu));
|
|
||||||
if (err < 0)
|
|
||||||
return err;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue