diff options
author | Takashi Iwai <tiwai@suse.de> | 2023-07-21 10:16:43 +0300 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2023-07-21 10:37:49 +0300 |
commit | 157ac57073bc33396ed719bfdcdccb72798a822d (patch) | |
tree | 8938bd57d65832a5584895173d35cfb7ae0a0ce3 /sound/pci/ice1712 | |
parent | b7bb11fa361f4319b1bbf7cc390ef4dd83236be3 (diff) | |
download | linux-157ac57073bc33396ed719bfdcdccb72798a822d.tar.xz |
ALSA: ice1712: Use the standard snd_ctl_add_followers() helper
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.
Link: https://lore.kernel.org/r/20230721071643.3631-5-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/pci/ice1712')
-rw-r--r-- | sound/pci/ice1712/juli.c | 19 | ||||
-rw-r--r-- | 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,10 +430,12 @@ 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; /* only capture SPDIF over AK4114 */ return snd_ak4114_build(spec->ak4114, NULL, 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,10 +786,12 @@ 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 */ return snd_ak4113_build(spec->ak4113, ice->pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream); |