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

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>

+5 -21
+5 -21
sound/i2c/other/ak4xxx-adda.c
··· 465 465 static int snd_akm4xxx_deemphasis_info(struct snd_kcontrol *kcontrol, 466 466 struct snd_ctl_elem_info *uinfo) 467 467 { 468 - static char *texts[4] = { 468 + static const char * const texts[4] = { 469 469 "44.1kHz", "Off", "48kHz", "32kHz", 470 470 }; 471 - uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; 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; 471 + return snd_ctl_enum_info(uinfo, 1, 4, texts); 479 472 } 480 473 481 474 static int snd_akm4xxx_deemphasis_get(struct snd_kcontrol *kcontrol, ··· 563 570 { 564 571 struct snd_akm4xxx *ak = snd_kcontrol_chip(kcontrol); 565 572 int mixer_ch = AK_GET_SHIFT(kcontrol->private_value); 566 - const char **input_names; 567 - unsigned int num_names, idx; 573 + unsigned int num_names; 568 574 569 575 num_names = ak4xxx_capture_num_inputs(ak, mixer_ch); 570 576 if (!num_names) 571 577 return -EINVAL; 572 - uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; 573 - uinfo->count = 1; 574 - uinfo->value.enumerated.items = num_names; 575 - idx = uinfo->value.enumerated.item; 576 - if (idx >= num_names) 577 - return -EINVAL; 578 - input_names = ak->adc_info[mixer_ch].input_names; 579 - strlcpy(uinfo->value.enumerated.name, input_names[idx], 580 - sizeof(uinfo->value.enumerated.name)); 581 - return 0; 578 + return snd_ctl_enum_info(uinfo, 1, num_names, 579 + ak->adc_info[mixer_ch].input_names); 582 580 } 583 581 584 582 static int ak4xxx_capture_source_get(struct snd_kcontrol *kcontrol,