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

ALSA: korg1212: Use snd_ctl_enum_info()

... and reduce the open codes. Also add missing const to text arrays.

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

+7 -19
+7 -19
sound/pci/korg1212/korg1212.c
··· 444 444 "Invalid" 445 445 }; 446 446 447 - static char *clockSourceTypeName[] = { "ADAT", "S/PDIF", "local" }; 447 + static const char * const clockSourceTypeName[] = { "ADAT", "S/PDIF", "local" }; 448 448 449 - static char *clockSourceName[] = { 449 + static const char * const clockSourceName[] = { 450 450 "ADAT at 44.1 kHz", 451 451 "ADAT at 48 kHz", 452 452 "S/PDIF at 44.1 kHz", ··· 455 455 "local clock at 48 kHz" 456 456 }; 457 457 458 - static char *channelName[] = { 458 + static const char * const channelName[] = { 459 459 "ADAT-1", 460 460 "ADAT-2", 461 461 "ADAT-3", ··· 1844 1844 static int snd_korg1212_control_route_info(struct snd_kcontrol *kcontrol, 1845 1845 struct snd_ctl_elem_info *uinfo) 1846 1846 { 1847 - uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; 1848 - uinfo->count = (kcontrol->private_value >= 8) ? 2 : 1; 1849 - uinfo->value.enumerated.items = kAudioChannels; 1850 - if (uinfo->value.enumerated.item > kAudioChannels-1) { 1851 - uinfo->value.enumerated.item = kAudioChannels-1; 1852 - } 1853 - strcpy(uinfo->value.enumerated.name, channelName[uinfo->value.enumerated.item]); 1854 - return 0; 1847 + return snd_ctl_enum_info(uinfo, 1848 + (kcontrol->private_value >= 8) ? 2 : 1, 1849 + kAudioChannels, channelName); 1855 1850 } 1856 1851 1857 1852 static int snd_korg1212_control_route_get(struct snd_kcontrol *kcontrol, ··· 1956 1961 static int snd_korg1212_control_sync_info(struct snd_kcontrol *kcontrol, 1957 1962 struct snd_ctl_elem_info *uinfo) 1958 1963 { 1959 - uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; 1960 - uinfo->count = 1; 1961 - uinfo->value.enumerated.items = 3; 1962 - if (uinfo->value.enumerated.item > 2) { 1963 - uinfo->value.enumerated.item = 2; 1964 - } 1965 - strcpy(uinfo->value.enumerated.name, clockSourceTypeName[uinfo->value.enumerated.item]); 1966 - return 0; 1964 + return snd_ctl_enum_info(uinfo, 1, 3, clockSourceTypeName); 1967 1965 } 1968 1966 1969 1967 static int snd_korg1212_control_sync_get(struct snd_kcontrol *kcontrol,