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

ALSA: hda: Use snd_ctl_enum_info()

... and reduce the open codes.

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

+2 -17
+2 -17
sound/pci/hda/hda_codec.c
··· 2927 2927 static const char * const texts[] = { 2928 2928 "On", "Off", "Follow Master" 2929 2929 }; 2930 - unsigned int index; 2931 2930 2932 - uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; 2933 - uinfo->count = 1; 2934 - uinfo->value.enumerated.items = 3; 2935 - index = uinfo->value.enumerated.item; 2936 - if (index >= 3) 2937 - index = 2; 2938 - strcpy(uinfo->value.enumerated.name, texts[index]); 2939 - return 0; 2931 + return snd_ctl_enum_info(uinfo, 1, 3, texts); 2940 2932 } 2941 2933 2942 2934 static int vmaster_mute_mode_get(struct snd_kcontrol *kcontrol, ··· 5187 5195 texts = texts_default; 5188 5196 } 5189 5197 5190 - uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; 5191 - uinfo->count = 1; 5192 - uinfo->value.enumerated.items = num_items; 5193 - if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items) 5194 - uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1; 5195 - strcpy(uinfo->value.enumerated.name, 5196 - texts[uinfo->value.enumerated.item]); 5197 - return 0; 5198 + return snd_ctl_enum_info(uinfo, 1, num_items, texts); 5198 5199 } 5199 5200 EXPORT_SYMBOL_GPL(snd_hda_enum_helper_info); 5200 5201