ALSA: ca0106: Use the standard snd_ctl_add_followers() helper
authorTakashi Iwai <tiwai@suse.de>
Fri, 21 Jul 2023 07:16:42 +0000 (09:16 +0200)
committerTakashi Iwai <tiwai@suse.de>
Fri, 21 Jul 2023 07:37:48 +0000 (09:37 +0200)
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.

Link: https://lore.kernel.org/r/20230721071643.3631-4-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/pci/ca0106/ca0106_mixer.c

index 2f37d2c3dd386bf7cc78ff128cc1356f44b6c513..1d5a899b2c243183d75574c7c27715b15a4fe500 100644 (file)
@@ -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");