aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2014-10-20 12:13:01 -0400
committerTakashi Iwai <tiwai@suse.de>2014-10-21 02:29:54 -0400
commit609e478b40aceaa07d14f1bada02a3874bac2c45 (patch)
tree66d4e6b83b1b152ee4835656223387e3be37ad18
parent41be5164ea09c92d551e8007d2543418e40f847a (diff)
ALSA: ak4xxx-adda: Use snd_ctl_enum_info()
... and reduce the open codes. Also add missing const to the text array. Signed-off-by: Takashi Iwai <tiwai@suse.de>
-rw-r--r--sound/i2c/other/ak4xxx-adda.c26
1 files changed, 5 insertions, 21 deletions
diff --git a/sound/i2c/other/ak4xxx-adda.c b/sound/i2c/other/ak4xxx-adda.c
index f3735e64791c..67dbfde837ab 100644
--- a/sound/i2c/other/ak4xxx-adda.c
+++ b/sound/i2c/other/ak4xxx-adda.c
@@ -465,17 +465,10 @@ static int snd_akm4xxx_stereo_volume_put(struct snd_kcontrol *kcontrol,
465static int snd_akm4xxx_deemphasis_info(struct snd_kcontrol *kcontrol, 465static int snd_akm4xxx_deemphasis_info(struct snd_kcontrol *kcontrol,
466 struct snd_ctl_elem_info *uinfo) 466 struct snd_ctl_elem_info *uinfo)
467{ 467{
468 static char *texts[4] = { 468 static const char * const texts[4] = {
469 "44.1kHz", "Off", "48kHz", "32kHz", 469 "44.1kHz", "Off", "48kHz", "32kHz",
470 }; 470 };
471 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; 471 return snd_ctl_enum_info(uinfo, 1, 4, texts);
472 uinfo->count = 1;
473 uinfo->value.enumerated.items = 4;
474 if (uinfo->value.enumerated.item >= 4)
475 uinfo->value.enumerated.item = 3;
476 strcpy(uinfo->value.enumerated.name,
477 texts[uinfo->value.enumerated.item]);
478 return 0;
479} 472}
480 473
481static int snd_akm4xxx_deemphasis_get(struct snd_kcontrol *kcontrol, 474static int snd_akm4xxx_deemphasis_get(struct snd_kcontrol *kcontrol,
@@ -570,22 +563,13 @@ static int ak4xxx_capture_source_info(struct snd_kcontrol *kcontrol,
570{ 563{
571 struct snd_akm4xxx *ak = snd_kcontrol_chip(kcontrol); 564 struct snd_akm4xxx *ak = snd_kcontrol_chip(kcontrol);
572 int mixer_ch = AK_GET_SHIFT(kcontrol->private_value); 565 int mixer_ch = AK_GET_SHIFT(kcontrol->private_value);
573 const char **input_names; 566 unsigned int num_names;
574 unsigned int num_names, idx;
575 567
576 num_names = ak4xxx_capture_num_inputs(ak, mixer_ch); 568 num_names = ak4xxx_capture_num_inputs(ak, mixer_ch);
577 if (!num_names) 569 if (!num_names)
578 return -EINVAL; 570 return -EINVAL;
579 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; 571 return snd_ctl_enum_info(uinfo, 1, num_names,
580 uinfo->count = 1; 572 ak->adc_info[mixer_ch].input_names);
581 uinfo->value.enumerated.items = num_names;
582 idx = uinfo->value.enumerated.item;
583 if (idx >= num_names)
584 return -EINVAL;
585 input_names = ak->adc_info[mixer_ch].input_names;
586 strlcpy(uinfo->value.enumerated.name, input_names[idx],
587 sizeof(uinfo->value.enumerated.name));
588 return 0;
589} 573}
590 574
591static int ak4xxx_capture_source_get(struct snd_kcontrol *kcontrol, 575static int ak4xxx_capture_source_get(struct snd_kcontrol *kcontrol,