]> git.karo-electronics.de Git - linux-beck.git/commitdiff
ALSA: es18xx: Use snd_ctl_enum_info()
authorTakashi Iwai <tiwai@suse.de>
Mon, 20 Oct 2014 16:14:24 +0000 (18:14 +0200)
committerTakashi Iwai <tiwai@suse.de>
Tue, 21 Oct 2014 06:32:47 +0000 (08:32 +0200)
... and reduce the open codes.  Also add missing const to text arrays.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/isa/es18xx.c

index 6faaac60161a8b629002d55f025ffd750e01da27..63e7323e218f829481713af1fd885d42e89153ef 100644 (file)
@@ -964,44 +964,28 @@ static int snd_es18xx_capture_close(struct snd_pcm_substream *substream)
 
 static int snd_es18xx_info_mux(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
 {
-       static char *texts5Source[5] = {
+       static const char * const texts5Source[5] = {
                "Mic", "CD", "Line", "Master", "Mix"
        };
-       static char *texts8Source[8] = {
+       static const char * const texts8Source[8] = {
                "Mic", "Mic Master", "CD", "AOUT",
                "Mic1", "Mix", "Line", "Master"
        };
        struct snd_es18xx *chip = snd_kcontrol_chip(kcontrol);
 
-       uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
-       uinfo->count = 1;
        switch (chip->version) {
        case 0x1868:
        case 0x1878:
-               uinfo->value.enumerated.items = 4;
-               if (uinfo->value.enumerated.item > 3)
-                       uinfo->value.enumerated.item = 3;
-               strcpy(uinfo->value.enumerated.name,
-                       texts5Source[uinfo->value.enumerated.item]);
-               break;
+               return snd_ctl_enum_info(uinfo, 1, 4, texts5Source);
        case 0x1887:
        case 0x1888:
-               uinfo->value.enumerated.items = 5;
-               if (uinfo->value.enumerated.item > 4)
-                       uinfo->value.enumerated.item = 4;
-               strcpy(uinfo->value.enumerated.name, texts5Source[uinfo->value.enumerated.item]);
-               break;
+               return snd_ctl_enum_info(uinfo, 1, 5, texts5Source);
        case 0x1869: /* DS somewhat contradictory for 1869: could be be 5 or 8 */
        case 0x1879:
-               uinfo->value.enumerated.items = 8;
-               if (uinfo->value.enumerated.item > 7)
-                       uinfo->value.enumerated.item = 7;
-               strcpy(uinfo->value.enumerated.name, texts8Source[uinfo->value.enumerated.item]);
-               break;
+               return snd_ctl_enum_info(uinfo, 1, 8, texts8Source);
        default:
                return -EINVAL;
        }
-       return 0;
 }
 
 static int snd_es18xx_get_mux(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)