aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci/hda/patch_via.c
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2011-06-17 16:15:26 +0200
committerTakashi Iwai <tiwai@suse.de>2011-06-20 16:23:57 +0200
commit291c9e33bf3f8ac201b24b8f9e481756d43d7df7 (patch)
tree854cf26a8f85958c19459bf8195a144daef0f50d /sound/pci/hda/patch_via.c
parente06e5a297474c8027beffe10541981845ca0c98b (diff)
ALSA: hda - Refactor ctl array handling in patch_via.c
No functional change. Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/pci/hda/patch_via.c')
-rw-r--r--sound/pci/hda/patch_via.c44
1 files changed, 23 insertions, 21 deletions
diff --git a/sound/pci/hda/patch_via.c b/sound/pci/hda/patch_via.c
index 30d1273f3c3..41398b07ba8 100644
--- a/sound/pci/hda/patch_via.c
+++ b/sound/pci/hda/patch_via.c
@@ -420,18 +420,34 @@ static const struct snd_kcontrol_new via_control_templates[] = {
/* add dynamic controls */
-static int __via_add_control(struct via_spec *spec, int type, const char *name,
- int idx, unsigned long val)
+static struct snd_kcontrol_new *__via_clone_ctl(struct via_spec *spec,
+ const struct snd_kcontrol_new *tmpl,
+ const char *name)
{
struct snd_kcontrol_new *knew;
snd_array_init(&spec->kctls, sizeof(*knew), 32);
knew = snd_array_new(&spec->kctls);
if (!knew)
- return -ENOMEM;
- *knew = via_control_templates[type];
- knew->name = kstrdup(name, GFP_KERNEL);
- if (!knew->name)
+ return NULL;
+ *knew = *tmpl;
+ if (!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;
if (get_amp_nid_(val))
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) \
__via_add_control(spec, type, name, 0, val)
-static struct snd_kcontrol_new *via_clone_control(struct via_spec *spec,
- 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;
-}
+#define via_clone_control(spec, tmpl) __via_clone_ctl(spec, tmpl, NULL)
static void via_free_kctls(struct hda_codec *codec)
{