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

ALSA: rme32: Use snd_ctl_enum_info()

... and reduce the open codes. Also add missing const to text arrays.

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

+10 -24
+10 -24
sound/pci/rme32.c
··· 1608 1608 struct snd_ctl_elem_info *uinfo) 1609 1609 { 1610 1610 struct rme32 *rme32 = snd_kcontrol_chip(kcontrol); 1611 - static char *texts[4] = { "Optical", "Coaxial", "Internal", "XLR" }; 1611 + static const char * const texts[4] = { 1612 + "Optical", "Coaxial", "Internal", "XLR" 1613 + }; 1614 + int num_items; 1612 1615 1613 - uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; 1614 - uinfo->count = 1; 1615 1616 switch (rme32->pci->device) { 1616 1617 case PCI_DEVICE_ID_RME_DIGI32: 1617 1618 case PCI_DEVICE_ID_RME_DIGI32_8: 1618 - uinfo->value.enumerated.items = 3; 1619 + num_items = 3; 1619 1620 break; 1620 1621 case PCI_DEVICE_ID_RME_DIGI32_PRO: 1621 - uinfo->value.enumerated.items = 4; 1622 + num_items = 4; 1622 1623 break; 1623 1624 default: 1624 1625 snd_BUG(); 1625 - break; 1626 + return -EINVAL; 1626 1627 } 1627 - if (uinfo->value.enumerated.item > 1628 - uinfo->value.enumerated.items - 1) { 1629 - uinfo->value.enumerated.item = 1630 - uinfo->value.enumerated.items - 1; 1631 - } 1632 - strcpy(uinfo->value.enumerated.name, 1633 - texts[uinfo->value.enumerated.item]); 1634 - return 0; 1628 + return snd_ctl_enum_info(uinfo, 1, num_items, texts); 1635 1629 } 1636 1630 static int 1637 1631 snd_rme32_get_inputtype_control(struct snd_kcontrol *kcontrol, ··· 1689 1695 snd_rme32_info_clockmode_control(struct snd_kcontrol *kcontrol, 1690 1696 struct snd_ctl_elem_info *uinfo) 1691 1697 { 1692 - static char *texts[4] = { "AutoSync", 1698 + static const char * const texts[4] = { "AutoSync", 1693 1699 "Internal 32.0kHz", 1694 1700 "Internal 44.1kHz", 1695 1701 "Internal 48.0kHz" }; 1696 1702 1697 - uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; 1698 - uinfo->count = 1; 1699 - uinfo->value.enumerated.items = 4; 1700 - if (uinfo->value.enumerated.item > 3) { 1701 - uinfo->value.enumerated.item = 3; 1702 - } 1703 - strcpy(uinfo->value.enumerated.name, 1704 - texts[uinfo->value.enumerated.item]); 1705 - return 0; 1703 + return snd_ctl_enum_info(uinfo, 1, 4, texts); 1706 1704 } 1707 1705 static int 1708 1706 snd_rme32_get_clockmode_control(struct snd_kcontrol *kcontrol,