Commit 2a1803a7291e82823effef0b48b0039324d224c6
Committed by
Takashi Iwai
1 parent
bed6896d0b
Exists in
master
and in
7 other branches
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>
Showing 2 changed files with 3 additions and 16 deletions Side-by-side Diff
sound/usb/midi.c
... | ... | @@ -1729,13 +1729,7 @@ |
1729 | 1729 | { |
1730 | 1730 | static const char *const names[] = { "High Load", "Light Load" }; |
1731 | 1731 | |
1732 | - info->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | |
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; | |
1732 | + return snd_ctl_enum_info(info, 1, 2, names); | |
1739 | 1733 | } |
1740 | 1734 | |
1741 | 1735 | static int roland_load_get(struct snd_kcontrol *kcontrol, |
sound/usb/mixer.c
... | ... | @@ -1633,18 +1633,11 @@ |
1633 | 1633 | static int mixer_ctl_selector_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) |
1634 | 1634 | { |
1635 | 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 | 1638 | if (snd_BUG_ON(!itemlist)) |
1639 | 1639 | return -EINVAL; |
1640 | - uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | |
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; | |
1640 | + return snd_ctl_enum_info(uinfo, 1, cval->max, itemlist); | |
1648 | 1641 | } |
1649 | 1642 | |
1650 | 1643 | /* get callback for selector unit */ |