Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ALSA: ice1712: Use snd_ctl_enum_info()

... and reduce the open codes.

Signed-off-by: Takashi Iwai <tiwai@suse.de>

+6 -37
+2 -14
sound/pci/ice1712/ews.c
··· 580 580 static const char * const texts[2] = { 581 581 "+4dBu", "-10dBV", 582 582 }; 583 - uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; 584 - uinfo->count = 1; 585 - uinfo->value.enumerated.items = 2; 586 - if (uinfo->value.enumerated.item >= 2) 587 - uinfo->value.enumerated.item = 1; 588 - strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]); 589 - return 0; 583 + return snd_ctl_enum_info(uinfo, 1, 2, texts); 590 584 } 591 585 592 586 static int snd_ice1712_ewx_io_sense_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) ··· 897 903 static const char * const texts[4] = { 898 904 "Internal", "Front Input", "Rear Input", "Wave Table" 899 905 }; 900 - uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; 901 - uinfo->count = 1; 902 - uinfo->value.enumerated.items = 4; 903 - if (uinfo->value.enumerated.item >= 4) 904 - uinfo->value.enumerated.item = 1; 905 - strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]); 906 - return 0; 906 + return snd_ctl_enum_info(uinfo, 1, 4, texts); 907 907 } 908 908 909 909 static int snd_ice1712_6fire_select_input_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
+4 -23
sound/pci/ice1712/ice1712.c
··· 1839 1839 "96000", /* 12: 7 */ 1840 1840 "IEC958 Input", /* 13: -- */ 1841 1841 }; 1842 - uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; 1843 - uinfo->count = 1; 1844 - uinfo->value.enumerated.items = 14; 1845 - if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items) 1846 - uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1; 1847 - strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]); 1848 - return 0; 1842 + return snd_ctl_enum_info(uinfo, 1, 14, texts); 1849 1843 } 1850 1844 1851 1845 static int snd_ice1712_pro_internal_clock_get(struct snd_kcontrol *kcontrol, ··· 1924 1930 "96000", /* 12: 7 */ 1925 1931 /* "IEC958 Input", 13: -- */ 1926 1932 }; 1927 - uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; 1928 - uinfo->count = 1; 1929 - uinfo->value.enumerated.items = 13; 1930 - if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items) 1931 - uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1; 1932 - strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]); 1933 - return 0; 1933 + return snd_ctl_enum_info(uinfo, 1, 13, texts); 1934 1934 } 1935 1935 1936 1936 static int snd_ice1712_pro_internal_clock_default_get(struct snd_kcontrol *kcontrol, ··· 2045 2057 "IEC958 In L", "IEC958 In R", /* 9-10 */ 2046 2058 "Digital Mixer", /* 11 - optional */ 2047 2059 }; 2048 - 2049 - uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; 2050 - uinfo->count = 1; 2051 - uinfo->value.enumerated.items = 2052 - snd_ctl_get_ioffidx(kcontrol, &uinfo->id) < 2 ? 12 : 11; 2053 - if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items) 2054 - uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1; 2055 - strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]); 2056 - return 0; 2060 + int num_items = snd_ctl_get_ioffidx(kcontrol, &uinfo->id) < 2 ? 12 : 11; 2061 + return snd_ctl_enum_info(uinfo, 1, num_items, texts); 2057 2062 } 2058 2063 2059 2064 static int snd_ice1712_pro_route_analog_get(struct snd_kcontrol *kcontrol,