diff options
author | Clemens Ladisch <clemens@ladisch.de> | 2011-01-10 10:30:13 -0500 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2011-01-10 10:47:07 -0500 |
commit | 2a1803a7291e82823effef0b48b0039324d224c6 (patch) | |
tree | aef83bacecd977821c94466fa38ced959343c6d4 | |
parent | bed6896d0be1de12eb6237a43a4beaaf7dcfb42c (diff) |
ALSA: usb-audio: use enum control info helper
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>
-rw-r--r-- | sound/usb/midi.c | 8 | ||||
-rw-r--r-- | sound/usb/mixer.c | 11 |
2 files changed, 3 insertions, 16 deletions
diff --git a/sound/usb/midi.c b/sound/usb/midi.c index 25bce7e5b1af..d7021cb01047 100644 --- a/sound/usb/midi.c +++ b/sound/usb/midi.c | |||
@@ -1729,13 +1729,7 @@ static int roland_load_info(struct snd_kcontrol *kcontrol, | |||
1729 | { | 1729 | { |
1730 | static const char *const names[] = { "High Load", "Light Load" }; | 1730 | static const char *const names[] = { "High Load", "Light Load" }; |
1731 | 1731 | ||
1732 | info->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | 1732 | return snd_ctl_enum_info(info, 1, 2, names); |
1733 | info->count = 1; | ||
1734 | info->value.enumerated.items = 2; | ||
1735 | if (info->value.enumerated.item > 1) | ||
1736 | info->value.enumerated.item = 1; | ||
1737 | strcpy(info->value.enumerated.name, names[info->value.enumerated.item]); | ||
1738 | return 0; | ||
1739 | } | 1733 | } |
1740 | 1734 | ||
1741 | static int roland_load_get(struct snd_kcontrol *kcontrol, | 1735 | static int roland_load_get(struct snd_kcontrol *kcontrol, |
diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c index f2d74d654b3c..7df89b3d7ded 100644 --- a/sound/usb/mixer.c +++ b/sound/usb/mixer.c | |||
@@ -1633,18 +1633,11 @@ static int parse_audio_extension_unit(struct mixer_build *state, int unitid, voi | |||
1633 | static int mixer_ctl_selector_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) | 1633 | static int mixer_ctl_selector_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) |
1634 | { | 1634 | { |
1635 | struct usb_mixer_elem_info *cval = kcontrol->private_data; | 1635 | struct usb_mixer_elem_info *cval = kcontrol->private_data; |
1636 | char **itemlist = (char **)kcontrol->private_value; | 1636 | const char **itemlist = (const char **)kcontrol->private_value; |
1637 | 1637 | ||
1638 | if (snd_BUG_ON(!itemlist)) | 1638 | if (snd_BUG_ON(!itemlist)) |
1639 | return -EINVAL; | 1639 | return -EINVAL; |
1640 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | 1640 | return snd_ctl_enum_info(uinfo, 1, cval->max, itemlist); |
1641 | uinfo->count = 1; | ||
1642 | uinfo->value.enumerated.items = cval->max; | ||
1643 | if (uinfo->value.enumerated.item >= cval->max) | ||
1644 | uinfo->value.enumerated.item = cval->max - 1; | ||
1645 | strlcpy(uinfo->value.enumerated.name, itemlist[uinfo->value.enumerated.item], | ||
1646 | sizeof(uinfo->value.enumerated.name)); | ||
1647 | return 0; | ||
1648 | } | 1641 | } |
1649 | 1642 | ||
1650 | /* get callback for selector unit */ | 1643 | /* get callback for selector unit */ |