From patchwork Fri Jul 21 07:16:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 704987 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C9E1EEB64DC for ; Fri, 21 Jul 2023 07:21:49 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id ACDA320C; Fri, 21 Jul 2023 09:20:57 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz ACDA320C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1689924107; bh=5aDbR0rcIvStY/gkqXGjQ2njbW6sQPKaMDoX3HBZfxE=; h=From:To:Subject:Date:In-Reply-To:References:List-Id:List-Archive: List-Help:List-Owner:List-Post:List-Subscribe:List-Unsubscribe: From; b=QfI52wWrmJrznCj7OjfuhGnRCmlvMchmfdep1yBGqcW9UZGjVo029emvuVpLzX9BT fQEiGVSbYQ9thipzBgufB9vbw8H9GHbcuTUdRDipq/PgFm3Vh3Q4bpWWVfmL/a8deg 5oMGqdZxL2w/BUTktVd5ph/TsPCtxnGZ1CRjtRnk= Received: by alsa1.perex.cz (Postfix, from userid 50401) id D4DCFF8007E; Fri, 21 Jul 2023 09:20:09 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 7B89BF80549; Fri, 21 Jul 2023 09:20:09 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 1E36BF80520; Fri, 21 Jul 2023 09:17:16 +0200 (CEST) Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id B421FF8032D for ; Fri, 21 Jul 2023 09:17:08 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz B421FF8032D Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key, unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=QsrdYL82; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=lpeTQfSE Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id D594B201BA; Fri, 21 Jul 2023 07:17:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1689923827; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kGd6lolCzPLtqPxMQTOpzs7vGp6Mt/dtkutzkMydvWo=; b=QsrdYL82NRCorWAFbCuFarIRSiKBHmoFT815/j1/3Bv1IOMC6MEZ9Lvicj+kcvrL1Vmw/E wLUhI/rXZFk5CGEobK7jSCcOG9NKTAPlWZH/BccbHnnEH3GFFSLf/MmSIdxxxSReKuBZZ9 qjW7BrM9/NpIKrJeaQacxX5H2Dax3PI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1689923827; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kGd6lolCzPLtqPxMQTOpzs7vGp6Mt/dtkutzkMydvWo=; b=lpeTQfSEo6cIgsJD+/3PB6hf1cohZTZEecBntqBDQdwb0JenMYyIFw8OcrJmS2/8atxZ7J lkaUhc/0UIg3vaCg== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id B7B1B139AF; Fri, 21 Jul 2023 07:17:07 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id OEMILPMwumRdLgAAMHmgww (envelope-from ); Fri, 21 Jul 2023 07:17:07 +0000 From: Takashi Iwai To: alsa-devel@alsa-project.org Subject: [PATCH v2 1/4] ALSA: vmaster: Add snd_ctl_add_followers() helper Date: Fri, 21 Jul 2023 09:16:40 +0200 Message-Id: <20230721071643.3631-2-tiwai@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230721071643.3631-1-tiwai@suse.de> References: <20230721071643.3631-1-tiwai@suse.de> MIME-Version: 1.0 Message-ID-Hash: MUNDIJSBMRNKWOILBZQB5TVLWA7H2UPS X-Message-ID-Hash: MUNDIJSBMRNKWOILBZQB5TVLWA7H2UPS X-MailFrom: tiwai@suse.de X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Add a new helper to add multiple vmaster followers in a shot. The same function was open-coded in various places, and this helper replaces them. Signed-off-by: Takashi Iwai --- include/sound/control.h | 3 +++ sound/core/vmaster.c | 28 ++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/include/sound/control.h b/include/sound/control.h index 69d950a34ca3..9a4f4f7138da 100644 --- a/include/sound/control.h +++ b/include/sound/control.h @@ -262,6 +262,9 @@ snd_ctl_add_follower(struct snd_kcontrol *master, struct snd_kcontrol *follower) return _snd_ctl_add_follower(master, follower, 0); } +int snd_ctl_add_followers(struct snd_card *card, struct snd_kcontrol *master, + const char * const *list); + /** * snd_ctl_add_follower_uncached - Add a virtual follower control * @master: vmaster element diff --git a/sound/core/vmaster.c b/sound/core/vmaster.c index d0f11f37889b..378d2c7c3d4a 100644 --- a/sound/core/vmaster.c +++ b/sound/core/vmaster.c @@ -280,6 +280,34 @@ int _snd_ctl_add_follower(struct snd_kcontrol *master, } EXPORT_SYMBOL(_snd_ctl_add_follower); +/** + * snd_ctl_add_followers - add multiple followers to vmaster + * @card: card instance + * @master: the target vmaster kcontrol object + * @list: NULL-terminated list of name strings of followers to be added + * + * Adds the multiple follower kcontrols with the given names. + * Returns 0 for success or a negative error code. + */ +int snd_ctl_add_followers(struct snd_card *card, struct snd_kcontrol *master, + const char * const *list) +{ + struct snd_kcontrol *follower; + int err; + + for (; *list; list++) { + follower = snd_ctl_find_id_mixer(card, *list); + if (follower) { + err = snd_ctl_add_follower(master, follower); + if (err < 0) + return err; + } + } + + return 0; +} +EXPORT_SYMBOL_GPL(snd_ctl_add_followers); + /* * ctl callbacks for master controls */ From patchwork Fri Jul 21 07:16:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 705307 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A11ABEB64DC for ; Fri, 21 Jul 2023 07:21:55 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 2603583B; Fri, 21 Jul 2023 09:21:03 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 2603583B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1689924113; bh=AdAa4a4l6t+0i6luIonpBKcVhVziMDJAtLhKuk14D78=; h=From:To:Subject:Date:In-Reply-To:References:List-Id:List-Archive: List-Help:List-Owner:List-Post:List-Subscribe:List-Unsubscribe: From; b=OUeMvPGOWtZcpwRcCzB9ApeJZqVnlShf7VwVbOEaGNTqU3ggHjKHgTo1utXvBv7V3 l1iUcL+clpzuI5VXK/5DSTevUgOkw55OhnIU05GSf3kuSXMXq75h1lVg7jEyYMvgov bMdNBKcB9vFt0o6PwwyWVYLOZ1gPIK6nmifZqHKA= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 721F2F80568; Fri, 21 Jul 2023 09:20:10 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 19CD9F80563; Fri, 21 Jul 2023 09:20:10 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 27EE1F8047D; Fri, 21 Jul 2023 09:17:18 +0200 (CEST) Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 3809FF804DA for ; Fri, 21 Jul 2023 09:17:08 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 3809FF804DA Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key, unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=bLYT8e+j; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=kG9MovDL Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id F11BD219BF; Fri, 21 Jul 2023 07:17:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1689923827; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=sWOtayF0fMT2IzKmQM67ZAWCMTbEJtvjXLr+Lli/Zi8=; b=bLYT8e+jgFO3pSqFs6Wp76zk0uPJkpyHlChpppS+IQ20EbOs1FV/Ho5k2hMny/NPok+ISg vtDJwTBwCgK3g4mMD61X89Ag73VFjouflQrN/YZACObTltrs7BQXkYZpZCj4tCYEgOfKxo qZyLvYFtFC2AcIv9T5AuKzv49tAKWSA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1689923827; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=sWOtayF0fMT2IzKmQM67ZAWCMTbEJtvjXLr+Lli/Zi8=; b=kG9MovDLIlaaVoH04IzxVszUQcZuJq8BMWb/+JVpSOYNf3LQOcXU3EWGR7q5apNA3lS9tc +L/txKlYb3xGUXAg== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id D7B2F134B0; Fri, 21 Jul 2023 07:17:07 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id IMXDM/MwumRdLgAAMHmgww (envelope-from ); Fri, 21 Jul 2023 07:17:07 +0000 From: Takashi Iwai To: alsa-devel@alsa-project.org Subject: [PATCH v2 2/4] ALSA: ac97: Use the standard snd_ctl_add_followers() helper Date: Fri, 21 Jul 2023 09:16:41 +0200 Message-Id: <20230721071643.3631-3-tiwai@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230721071643.3631-1-tiwai@suse.de> References: <20230721071643.3631-1-tiwai@suse.de> MIME-Version: 1.0 Message-ID-Hash: U6HMLU2HAERADKQXU7M7QXURNI3KCJON X-Message-ID-Hash: U6HMLU2HAERADKQXU7M7QXURNI3KCJON X-MailFrom: tiwai@suse.de X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Instead of open-code, use the new standard helper to manage vmaster stuff for code simplification. Except for a debug print, there should be no functional change. Signed-off-by: Takashi Iwai --- v1->v2: drop unnecessary check of the error condition sound/pci/ac97/ac97_patch.c | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/sound/pci/ac97/ac97_patch.c b/sound/pci/ac97/ac97_patch.c index ccfd9c7bf900..1d786bd5ce3e 100644 --- a/sound/pci/ac97/ac97_patch.c +++ b/sound/pci/ac97/ac97_patch.c @@ -3440,7 +3440,6 @@ static int snd_ac97_add_vmaster(struct snd_ac97 *ac97, char *name, const char * const *followers) { struct snd_kcontrol *kctl; - const char * const *s; int err; kctl = snd_ctl_make_virtual_master(name, tlv); @@ -3450,20 +3449,7 @@ static int snd_ac97_add_vmaster(struct snd_ac97 *ac97, char *name, if (err < 0) return err; - for (s = followers; *s; s++) { - struct snd_kcontrol *sctl; - - sctl = snd_ac97_find_mixer_ctl(ac97, *s); - if (!sctl) { - dev_dbg(ac97->bus->card->dev, - "Cannot find follower %s, skipped\n", *s); - continue; - } - err = snd_ctl_add_follower(kctl, sctl); - if (err < 0) - return err; - } - return 0; + return snd_ctl_add_followers(ac97->bus->card, kctl, followers); } static int patch_vt1616_specific(struct snd_ac97 * ac97) From patchwork Fri Jul 21 07:16:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 705308 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7C0D4EB64DC for ; Fri, 21 Jul 2023 07:21:28 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 5B4441F6; Fri, 21 Jul 2023 09:20:35 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 5B4441F6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1689924085; bh=qFSg4Nrsi/B+e2tlyqbg1y99VJaof9FeiooHLd1AtWQ=; h=From:To:Subject:Date:In-Reply-To:References:List-Id:List-Archive: List-Help:List-Owner:List-Post:List-Subscribe:List-Unsubscribe: From; b=fEnkMYwfFYHYU+N3LT73T/QWCzoY+/b7c87hA7l+YsPUKu8MDkuhA2jCVZ2lqRjRX i9yc42ECAcoaXaYnDSMhUzzzgtJDjRREVoHDSu0LXFcusuBsFxBMrMF0wYV++MsTFs 64MZhTCHTZm/yhISV7C05iPI5EviYVhUUPtFoHwA= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 34347F80494; Fri, 21 Jul 2023 09:20:06 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id CFADBF8007E; Fri, 21 Jul 2023 09:20:05 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id EE71FF80527; Fri, 21 Jul 2023 09:17:13 +0200 (CEST) Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 944CCF8027B for ; Fri, 21 Jul 2023 09:17:08 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 944CCF8027B Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key, unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=OwoZ1ohk; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=zzWcHCqM Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 1A5E1219C9; Fri, 21 Jul 2023 07:17:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1689923828; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/ArAGPYt99/duFoPW1QhLnK4nczAggyoc5eHLNDPC00=; b=OwoZ1ohk2T8GUhVGS0lyHPv250GAMCoK9MGCPq3txH5vUwz3s/2oksIzPojL1FaVLmHGqv ihP71DY18wKHu/fD/oZJLqfHUTXoq97hf8vfWf2NLQSMx+c8RmJoXNcjfjD6AFyrDGCx+2 SU/qfg5FYpiH99dSWMOMG52Y2kU32BY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1689923828; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/ArAGPYt99/duFoPW1QhLnK4nczAggyoc5eHLNDPC00=; b=zzWcHCqMwQljuQsENbuVo/ZseoCvi38bsz0jeG/mMslz5+4eGDu2nroX/2A3qDgWkYvETF 1Ap29PpZHO4kq8AA== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id F3EF4139AF; Fri, 21 Jul 2023 07:17:07 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id kM7FOvMwumRdLgAAMHmgww (envelope-from ); Fri, 21 Jul 2023 07:17:07 +0000 From: Takashi Iwai To: alsa-devel@alsa-project.org Subject: [PATCH v2 3/4] ALSA: ca0106: Use the standard snd_ctl_add_followers() helper Date: Fri, 21 Jul 2023 09:16:42 +0200 Message-Id: <20230721071643.3631-4-tiwai@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230721071643.3631-1-tiwai@suse.de> References: <20230721071643.3631-1-tiwai@suse.de> MIME-Version: 1.0 Message-ID-Hash: X7GYY3I5WSE254ALRFBJGFC7ACMNYUTE X-Message-ID-Hash: X7GYY3I5WSE254ALRFBJGFC7ACMNYUTE X-MailFrom: tiwai@suse.de X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Instead of open-code, use the new standard helper to manage vmaster stuff for code simplification. Also, handle the errors from the helper more properly instead of silently ignoring. Signed-off-by: Takashi Iwai --- sound/pci/ca0106/ca0106_mixer.c | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/sound/pci/ca0106/ca0106_mixer.c b/sound/pci/ca0106/ca0106_mixer.c index 2f37d2c3dd38..1d5a899b2c24 100644 --- a/sound/pci/ca0106/ca0106_mixer.c +++ b/sound/pci/ca0106/ca0106_mixer.c @@ -751,17 +751,6 @@ static const char * const follower_sws[] = { NULL }; -static void add_followers(struct snd_card *card, - struct snd_kcontrol *master, const char * const *list) -{ - for (; *list; list++) { - struct snd_kcontrol *follower = - snd_ctl_find_id_mixer(card, *list); - if (follower) - snd_ctl_add_follower(master, follower); - } -} - int snd_ca0106_mixer(struct snd_ca0106 *emu) { int err; @@ -843,7 +832,9 @@ int snd_ca0106_mixer(struct snd_ca0106 *emu) err = snd_ctl_add(card, vmaster); if (err < 0) return err; - add_followers(card, vmaster, follower_vols); + err = snd_ctl_add_followers(card, vmaster, follower_vols); + if (err < 0) + return err; if (emu->details->spi_dac) { vmaster = snd_ctl_make_virtual_master("Master Playback Switch", @@ -853,7 +844,9 @@ int snd_ca0106_mixer(struct snd_ca0106 *emu) err = snd_ctl_add(card, vmaster); if (err < 0) return err; - add_followers(card, vmaster, follower_sws); + err = snd_ctl_add_followers(card, vmaster, follower_sws); + if (err < 0) + return err; } strcpy(card->mixername, "CA0106"); From patchwork Fri Jul 21 07:16:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 704986 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 87137C001DC for ; Fri, 21 Jul 2023 07:22:21 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id CA52784C; Fri, 21 Jul 2023 09:21:23 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz CA52784C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1689924134; bh=/GkoOe3o90wZZyP0e0Y0uFIPGWntQPNFMNFR+AcvQIs=; h=From:To:Subject:Date:In-Reply-To:References:List-Id:List-Archive: List-Help:List-Owner:List-Post:List-Subscribe:List-Unsubscribe: From; b=aiMBTKDM7YY97CtqbAhjVNMsA/lR8/Q/Cr2rBwBj7/DYUKvkF4LUzt8mTbpoGO7sf m/fD9KIivyilDBAKaEHAb1mvDoqJHDkfpnyUMnopRFGosq4emtKTXS+CRH+ITxtDqQ 4L0sraduoYH7rtQ93pd30BtlyYu+b5AgjExTGe7I= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 0FECDF8057A; Fri, 21 Jul 2023 09:20:10 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 9686CF8057A; Fri, 21 Jul 2023 09:20:10 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 4915FF8047D; Fri, 21 Jul 2023 09:17:20 +0200 (CEST) Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id F0007F80494 for ; Fri, 21 Jul 2023 09:17:08 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz F0007F80494 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key, unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=YqbBNGa5; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=3STythtX Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 38A23201D9; Fri, 21 Jul 2023 07:17:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1689923828; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=nTQ14JC6mQ5BgjoLhLF6hiXxW4MD7lvfHG7W+rD963g=; b=YqbBNGa5SEzVbzlXe+mlVui0YbybUuQ28o4NmfBmSvy/Ec0GlZE0BxC6Zf8h9maZZSSZff o4cT6UvhaOspBiG5A9iwio++YDoJclKPtN1zPwhskVgdFGKQaF6Gj5B63X5vdiKZLJA81y iKEMe5qCr2E4pJHToUdQWPEqYLuSUZ0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1689923828; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=nTQ14JC6mQ5BgjoLhLF6hiXxW4MD7lvfHG7W+rD963g=; b=3STythtXjE/gj+9g1jCG5rz/NRkc7BY8xt/fK3598+SXOsgNtmmwAjErt310phVJ8cphsK oN88pvvwjkuxkdBw== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 1D1CC134B0; Fri, 21 Jul 2023 07:17:08 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id QD1UBvQwumRdLgAAMHmgww (envelope-from ); Fri, 21 Jul 2023 07:17:08 +0000 From: Takashi Iwai To: alsa-devel@alsa-project.org Subject: [PATCH v2 4/4] ALSA: ice1712: Use the standard snd_ctl_add_followers() helper Date: Fri, 21 Jul 2023 09:16:43 +0200 Message-Id: <20230721071643.3631-5-tiwai@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230721071643.3631-1-tiwai@suse.de> References: <20230721071643.3631-1-tiwai@suse.de> MIME-Version: 1.0 Message-ID-Hash: QX4OG5MGQRQLEVYYNB3AY6V4JYV3XGHA X-Message-ID-Hash: QX4OG5MGQRQLEVYYNB3AY6V4JYV3XGHA X-MailFrom: tiwai@suse.de X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Instead of open-code, use the new standard helper to manage vmaster stuff for code simplification. Also, handle the errors from the helper more properly instead of silently ignoring. The code changes the call order of snd_ctl_add() of the vmaster object and its followers for avoiding the possible memory leaks at error path. But there should be no difference in the functionality. Signed-off-by: Takashi Iwai --- sound/pci/ice1712/juli.c | 19 +++---------------- sound/pci/ice1712/quartet.c | 15 +++------------ 2 files changed, 6 insertions(+), 28 deletions(-) diff --git a/sound/pci/ice1712/juli.c b/sound/pci/ice1712/juli.c index d80ecf1edc16..d679842ae1bd 100644 --- a/sound/pci/ice1712/juli.c +++ b/sound/pci/ice1712/juli.c @@ -408,21 +408,6 @@ static const char * const follower_vols[] = { static DECLARE_TLV_DB_SCALE(juli_master_db_scale, -6350, 50, 1); -static void add_followers(struct snd_card *card, - struct snd_kcontrol *master, - const char * const *list) -{ - for (; *list; list++) { - struct snd_kcontrol *follower = - snd_ctl_find_id_mixer(card, *list); - /* dev_dbg(card->dev, "add_followers - %s\n", *list); */ - if (follower) { - /* dev_dbg(card->dev, "follower %s found\n", *list); */ - snd_ctl_add_follower(master, follower); - } - } -} - static int juli_add_controls(struct snd_ice1712 *ice) { struct juli_spec *spec = ice->spec; @@ -445,8 +430,10 @@ static int juli_add_controls(struct snd_ice1712 *ice) juli_master_db_scale); if (!vmaster) return -ENOMEM; - add_followers(ice->card, vmaster, follower_vols); err = snd_ctl_add(ice->card, vmaster); + if (err < 0) + return err; + err = snd_ctl_add_followers(ice->card, vmaster, follower_vols); if (err < 0) return err; diff --git a/sound/pci/ice1712/quartet.c b/sound/pci/ice1712/quartet.c index 9450c4b104f7..f61ee9f5c754 100644 --- a/sound/pci/ice1712/quartet.c +++ b/sound/pci/ice1712/quartet.c @@ -766,17 +766,6 @@ static const char * const follower_vols[] = { static DECLARE_TLV_DB_SCALE(qtet_master_db_scale, -6350, 50, 1); -static void add_followers(struct snd_card *card, - struct snd_kcontrol *master, const char * const *list) -{ - for (; *list; list++) { - struct snd_kcontrol *follower = - snd_ctl_find_id_mixer(card, *list); - if (follower) - snd_ctl_add_follower(master, follower); - } -} - static int qtet_add_controls(struct snd_ice1712 *ice) { struct qtet_spec *spec = ice->spec; @@ -797,8 +786,10 @@ static int qtet_add_controls(struct snd_ice1712 *ice) qtet_master_db_scale); if (!vmaster) return -ENOMEM; - add_followers(ice->card, vmaster, follower_vols); err = snd_ctl_add(ice->card, vmaster); + if (err < 0) + return err; + err = snd_ctl_add_followers(ice->card, vmaster, follower_vols); if (err < 0) return err; /* only capture SPDIF over AK4113 */