Commit ae07eb9b authored by Takashi Iwai's avatar Takashi Iwai

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.deSigned-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent ebc1bfeb
......@@ -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
......
......@@ -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
*/
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment