ALSA: usb-audio: use enum control info helper
authorClemens Ladisch <clemens@ladisch.de>
Mon, 10 Jan 2011 15:30:13 +0000 (16:30 +0100)
committerTakashi Iwai <tiwai@suse.de>
Mon, 10 Jan 2011 15:47:07 +0000 (16:47 +0100)
Simplify info callbacks by using the snd_ctl_enum_info() helper function.

Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/usb/midi.c
sound/usb/mixer.c

index 25bce7e5b1afd09cf1fdac8ad7d5f77e61c0eca9..d7021cb01047c21e16bfbbc385c7d3f127f2fb6e 100644 (file)
@@ -1729,13 +1729,7 @@ static int roland_load_info(struct snd_kcontrol *kcontrol,
 {
        static const char *const names[] = { "High Load", "Light Load" };
 
-       info->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
-       info->count = 1;
-       info->value.enumerated.items = 2;
-       if (info->value.enumerated.item > 1)
-               info->value.enumerated.item = 1;
-       strcpy(info->value.enumerated.name, names[info->value.enumerated.item]);
-       return 0;
+       return snd_ctl_enum_info(info, 1, 2, names);
 }
 
 static int roland_load_get(struct snd_kcontrol *kcontrol,
index f2d74d654b3c3302b6dbe353ae8be95484c16ccf..7df89b3d7ded2b73d5bd1731b8803c34af6393f5 100644 (file)
@@ -1633,18 +1633,11 @@ static int parse_audio_extension_unit(struct mixer_build *state, int unitid, voi
 static int mixer_ctl_selector_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
 {
        struct usb_mixer_elem_info *cval = kcontrol->private_data;
-       char **itemlist = (char **)kcontrol->private_value;
+       const char **itemlist = (const char **)kcontrol->private_value;
 
        if (snd_BUG_ON(!itemlist))
                return -EINVAL;
-       uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
-       uinfo->count = 1;
-       uinfo->value.enumerated.items = cval->max;
-       if (uinfo->value.enumerated.item >= cval->max)
-               uinfo->value.enumerated.item = cval->max - 1;
-       strlcpy(uinfo->value.enumerated.name, itemlist[uinfo->value.enumerated.item],
-               sizeof(uinfo->value.enumerated.name));
-       return 0;
+       return snd_ctl_enum_info(uinfo, 1, cval->max, itemlist);
 }
 
 /* get callback for selector unit */