All of lore.kernel.org
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: alsa-devel@alsa-project.org
Subject: [PATCH 13/16] ALSA: hda/cirrus - Simplify creation of new controls
Date: Fri, 22 Jun 2018 11:53:49 +0200	[thread overview]
Message-ID: <20180622095352.19451-14-tiwai@suse.de> (raw)
In-Reply-To: <20180622095352.19451-1-tiwai@suse.de>

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>
---
 sound/pci/hda/patch_cirrus.c | 29 +++++++++--------------------
 1 file 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,
-- 
2.17.1

  parent reply	other threads:[~2018-06-22  9:53 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-22  9:53 [PATCH 00/16] ALSA: hda - GPIO cleanups Takashi Iwai
2018-06-22  9:53 ` [PATCH 01/16] ALSA: hda/realtek - Allow skipping spec->init_amp detection Takashi Iwai
2018-06-22  9:53 ` [PATCH 02/16] ALSA: hda/realtek - Manage GPIO bits commonly Takashi Iwai
2018-06-22  9:53 ` [PATCH 03/16] ALSA: hda/realtek - Add GPIO data update helper Takashi Iwai
2018-06-22  9:53 ` [PATCH 04/16] ALSA: hda/realtek - Consolidate gpio_data and gpio_led Takashi Iwai
2018-06-22  9:53 ` [PATCH 05/16] ALSA: hda/realtek - Simplify alc885_fixup_macpro_gpio() Takashi Iwai
2018-06-22  9:53 ` [PATCH 06/16] ALSA: hda/realtek - Simplify mute LED GPIO handling Takashi Iwai
2018-06-22  9:53 ` [PATCH 07/16] ALSA: hda/realtek - Convert some manual GPIO setups Takashi Iwai
2018-06-22  9:53 ` [PATCH 08/16] ALSA: hda/realtek - Simplify Dell XPS13 GPIO handling Takashi Iwai
2018-06-22  9:53 ` [PATCH 09/16] ALSA: hda/realtek - Use common GPIO mask for ALC660VD ASUS fixup Takashi Iwai
2018-06-22  9:53 ` [PATCH 10/16] ALSA: hda/realtek - Use common helper for creating ALC268 beep controls Takashi Iwai
2018-06-22  9:53 ` [PATCH 11/16] ALSA: hda/realtek - Use common helper for creating " Takashi Iwai
2018-06-22  9:53 ` [PATCH 12/16] ALSA: hda/conexant - Clean up beep code Takashi Iwai
2018-06-22  9:53 ` Takashi Iwai [this message]
2018-06-22  9:53 ` [PATCH 14/16] ALSA: hda/via - Rewrite with error goto Takashi Iwai
2018-06-22  9:53 ` [PATCH 15/16] ALSA: hda/via - Simplify control management Takashi Iwai
2018-06-22  9:53 ` [PATCH 16/16] ALSA: hda/via - Use standard verb containers Takashi Iwai

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180622095352.19451-14-tiwai@suse.de \
    --to=tiwai@suse.de \
    --cc=alsa-devel@alsa-project.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.