ALSA: hda - Refactor ctl array handling in patch_via.c
No functional change. Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
@ -420,18 +420,34 @@ static const struct snd_kcontrol_new via_control_templates[] = {
|
|||||||
|
|
||||||
|
|
||||||
/* add dynamic controls */
|
/* add dynamic controls */
|
||||||
static int __via_add_control(struct via_spec *spec, int type, const char *name,
|
static struct snd_kcontrol_new *__via_clone_ctl(struct via_spec *spec,
|
||||||
int idx, unsigned long val)
|
const struct snd_kcontrol_new *tmpl,
|
||||||
|
const char *name)
|
||||||
{
|
{
|
||||||
struct snd_kcontrol_new *knew;
|
struct snd_kcontrol_new *knew;
|
||||||
|
|
||||||
snd_array_init(&spec->kctls, sizeof(*knew), 32);
|
snd_array_init(&spec->kctls, sizeof(*knew), 32);
|
||||||
knew = snd_array_new(&spec->kctls);
|
knew = snd_array_new(&spec->kctls);
|
||||||
if (!knew)
|
if (!knew)
|
||||||
return -ENOMEM;
|
return NULL;
|
||||||
*knew = via_control_templates[type];
|
*knew = *tmpl;
|
||||||
knew->name = kstrdup(name, GFP_KERNEL);
|
if (!name)
|
||||||
if (!knew->name)
|
name = tmpl->name;
|
||||||
|
if (name) {
|
||||||
|
knew->name = kstrdup(name, GFP_KERNEL);
|
||||||
|
if (!knew->name)
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
return knew;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int __via_add_control(struct via_spec *spec, int type, const char *name,
|
||||||
|
int idx, unsigned long val)
|
||||||
|
{
|
||||||
|
struct snd_kcontrol_new *knew;
|
||||||
|
|
||||||
|
knew = __via_clone_ctl(spec, &via_control_templates[type], name);
|
||||||
|
if (!knew)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
if (get_amp_nid_(val))
|
if (get_amp_nid_(val))
|
||||||
knew->subdevice = HDA_SUBDEV_AMP_FLAG;
|
knew->subdevice = HDA_SUBDEV_AMP_FLAG;
|
||||||
@ -442,21 +458,7 @@ static int __via_add_control(struct via_spec *spec, int type, const char *name,
|
|||||||
#define via_add_control(spec, type, name, val) \
|
#define via_add_control(spec, type, name, val) \
|
||||||
__via_add_control(spec, type, name, 0, val)
|
__via_add_control(spec, type, name, 0, val)
|
||||||
|
|
||||||
static struct snd_kcontrol_new *via_clone_control(struct via_spec *spec,
|
#define via_clone_control(spec, tmpl) __via_clone_ctl(spec, tmpl, NULL)
|
||||||
const struct snd_kcontrol_new *tmpl)
|
|
||||||
{
|
|
||||||
struct snd_kcontrol_new *knew;
|
|
||||||
|
|
||||||
snd_array_init(&spec->kctls, sizeof(*knew), 32);
|
|
||||||
knew = snd_array_new(&spec->kctls);
|
|
||||||
if (!knew)
|
|
||||||
return NULL;
|
|
||||||
*knew = *tmpl;
|
|
||||||
knew->name = kstrdup(tmpl->name, GFP_KERNEL);
|
|
||||||
if (!knew->name)
|
|
||||||
return NULL;
|
|
||||||
return knew;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void via_free_kctls(struct hda_codec *codec)
|
static void via_free_kctls(struct hda_codec *codec)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user