mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-05-24 10:39:52 +00:00
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>
This commit is contained in:
parent
08455ace3c
commit
11c6ef7c8d
1 changed files with 10 additions and 24 deletions
|
@ -1608,30 +1608,24 @@ snd_rme32_info_inputtype_control(struct snd_kcontrol *kcontrol,
|
||||||
struct snd_ctl_elem_info *uinfo)
|
struct snd_ctl_elem_info *uinfo)
|
||||||
{
|
{
|
||||||
struct rme32 *rme32 = snd_kcontrol_chip(kcontrol);
|
struct rme32 *rme32 = snd_kcontrol_chip(kcontrol);
|
||||||
static char *texts[4] = { "Optical", "Coaxial", "Internal", "XLR" };
|
static const char * const texts[4] = {
|
||||||
|
"Optical", "Coaxial", "Internal", "XLR"
|
||||||
|
};
|
||||||
|
int num_items;
|
||||||
|
|
||||||
uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
|
|
||||||
uinfo->count = 1;
|
|
||||||
switch (rme32->pci->device) {
|
switch (rme32->pci->device) {
|
||||||
case PCI_DEVICE_ID_RME_DIGI32:
|
case PCI_DEVICE_ID_RME_DIGI32:
|
||||||
case PCI_DEVICE_ID_RME_DIGI32_8:
|
case PCI_DEVICE_ID_RME_DIGI32_8:
|
||||||
uinfo->value.enumerated.items = 3;
|
num_items = 3;
|
||||||
break;
|
break;
|
||||||
case PCI_DEVICE_ID_RME_DIGI32_PRO:
|
case PCI_DEVICE_ID_RME_DIGI32_PRO:
|
||||||
uinfo->value.enumerated.items = 4;
|
num_items = 4;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
snd_BUG();
|
snd_BUG();
|
||||||
break;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
if (uinfo->value.enumerated.item >
|
return snd_ctl_enum_info(uinfo, 1, num_items, texts);
|
||||||
uinfo->value.enumerated.items - 1) {
|
|
||||||
uinfo->value.enumerated.item =
|
|
||||||
uinfo->value.enumerated.items - 1;
|
|
||||||
}
|
|
||||||
strcpy(uinfo->value.enumerated.name,
|
|
||||||
texts[uinfo->value.enumerated.item]);
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
static int
|
static int
|
||||||
snd_rme32_get_inputtype_control(struct snd_kcontrol *kcontrol,
|
snd_rme32_get_inputtype_control(struct snd_kcontrol *kcontrol,
|
||||||
|
@ -1695,20 +1689,12 @@ static int
|
||||||
snd_rme32_info_clockmode_control(struct snd_kcontrol *kcontrol,
|
snd_rme32_info_clockmode_control(struct snd_kcontrol *kcontrol,
|
||||||
struct snd_ctl_elem_info *uinfo)
|
struct snd_ctl_elem_info *uinfo)
|
||||||
{
|
{
|
||||||
static char *texts[4] = { "AutoSync",
|
static const char * const texts[4] = { "AutoSync",
|
||||||
"Internal 32.0kHz",
|
"Internal 32.0kHz",
|
||||||
"Internal 44.1kHz",
|
"Internal 44.1kHz",
|
||||||
"Internal 48.0kHz" };
|
"Internal 48.0kHz" };
|
||||||
|
|
||||||
uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
|
return snd_ctl_enum_info(uinfo, 1, 4, texts);
|
||||||
uinfo->count = 1;
|
|
||||||
uinfo->value.enumerated.items = 4;
|
|
||||||
if (uinfo->value.enumerated.item > 3) {
|
|
||||||
uinfo->value.enumerated.item = 3;
|
|
||||||
}
|
|
||||||
strcpy(uinfo->value.enumerated.name,
|
|
||||||
texts[uinfo->value.enumerated.item]);
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
static int
|
static int
|
||||||
snd_rme32_get_clockmode_control(struct snd_kcontrol *kcontrol,
|
snd_rme32_get_clockmode_control(struct snd_kcontrol *kcontrol,
|
||||||
|
|
Loading…
Add table
Reference in a new issue