diff options
author | Takashi Iwai <tiwai@suse.de> | 2023-07-21 10:16:40 +0300 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2023-07-21 10:37:47 +0300 |
commit | ae07eb9bf23e1a52cdb28222a71eb014131018d8 (patch) | |
tree | 3f36aecc5b779a1a9c2bbd3c669f3b714a7d19da /sound/core | |
parent | ebc1bfebdacab9e7fd77eec2c5dbcef73980ab00 (diff) | |
download | linux-ae07eb9bf23e1a52cdb28222a71eb014131018d8.tar.xz |
ALSA: vmaster: Add snd_ctl_add_followers() helper
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.
Link: https://lore.kernel.org/r/20230721071643.3631-2-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/core')
-rw-r--r-- | sound/core/vmaster.c | 28 |
1 files changed, 28 insertions, 0 deletions
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 */ |