summaryrefslogtreecommitdiff
path: root/sound/pci/hda/patch_cirrus.c
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2018-06-20 18:10:51 +0300
committerTakashi Iwai <tiwai@suse.de>2018-06-25 11:04:26 +0300
commit0785b0ecb8fa960b4f49010d0679d174efad423c (patch)
treec7d53d462cecaaf3070d2557fbababce7f09b59b /sound/pci/hda/patch_cirrus.c
parent51e19ca5f7555802687324d3bee3bc6b7df240d4 (diff)
downloadlinux-0785b0ecb8fa960b4f49010d0679d174efad423c.tar.xz
ALSA: hda/cirrus - Simplify creation of new controls
This patch moves the mixer creation code in Cirrus codec driver from its own build_controls callback to snd_hda_gen_add_kctl() for simplification. As a bonus, this allows us to remove the cs421x_build_controls as it becomes identical with snd_hda_gen_build_controls(). Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/pci/hda/patch_cirrus.c')
-rw-r--r--sound/pci/hda/patch_cirrus.c29
1 files changed, 9 insertions, 20 deletions
diff --git a/sound/pci/hda/patch_cirrus.c b/sound/pci/hda/patch_cirrus.c
index d6e079f4ec09..a7f91be45194 100644
--- a/sound/pci/hda/patch_cirrus.c
+++ b/sound/pci/hda/patch_cirrus.c
@@ -1096,25 +1096,6 @@ static int cs421x_init(struct hda_codec *codec)
return 0;
}
-static int cs421x_build_controls(struct hda_codec *codec)
-{
- struct cs_spec *spec = codec->spec;
- int err;
-
- err = snd_hda_gen_build_controls(codec);
- if (err < 0)
- return err;
-
- if (spec->gen.autocfg.speaker_outs &&
- spec->vendor_nid == CS4210_VENDOR_NID) {
- err = snd_hda_ctl_add(codec, 0,
- snd_ctl_new1(&cs421x_speaker_boost_ctl, codec));
- if (err < 0)
- return err;
- }
- return 0;
-}
-
static void fix_volume_caps(struct hda_codec *codec, hda_nid_t dac)
{
unsigned int caps;
@@ -1144,6 +1125,14 @@ static int cs421x_parse_auto_config(struct hda_codec *codec)
return err;
parse_cs421x_digital(codec);
+
+ if (spec->gen.autocfg.speaker_outs &&
+ spec->vendor_nid == CS4210_VENDOR_NID) {
+ if (!snd_hda_gen_add_kctl(&spec->gen, NULL,
+ &cs421x_speaker_boost_ctl))
+ return -ENOMEM;
+ }
+
return 0;
}
@@ -1175,7 +1164,7 @@ static int cs421x_suspend(struct hda_codec *codec)
#endif
static const struct hda_codec_ops cs421x_patch_ops = {
- .build_controls = cs421x_build_controls,
+ .build_controls = snd_hda_gen_build_controls,
.build_pcms = snd_hda_gen_build_pcms,
.init = cs421x_init,
.free = cs_free,