]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
ASoC: soc-card: Use snd_ctl_find_id_mixer() instead of open-coding
authorRichard Fitzgerald <rf@opensource.cirrus.com>
Mon, 1 Apr 2024 10:02:09 +0000 (10:02 +0000)
committerMark Brown <broonie@kernel.org>
Tue, 2 Apr 2024 14:54:48 +0000 (15:54 +0100)
Use the snd_ctl_find_id_mixer[_locked]() wrapper in
snd_soc_card_get_kcontrol[_locked]() instead of open-coding a custom
list walk of the card controls list.

Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Reviewed-by: Takashi Iwai <tiwai@suse.de>
Link: https://msgid.link/r/20240401100210.61277-3-rf@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/soc-card.c

index 8a2f163da6bc9e8e61fc1f196f3b89556815cafe..0a3104d4ad2356d2406c9e3e65e3761954945028 100644 (file)
@@ -32,33 +32,20 @@ static inline int _soc_card_ret(struct snd_soc_card *card,
 struct snd_kcontrol *snd_soc_card_get_kcontrol_locked(struct snd_soc_card *soc_card,
                                                      const char *name)
 {
-       struct snd_card *card = soc_card->snd_card;
-       struct snd_kcontrol *kctl;
-
-       /* must be held read or write */
-       lockdep_assert_held(&card->controls_rwsem);
-
        if (unlikely(!name))
                return NULL;
 
-       list_for_each_entry(kctl, &card->controls, list)
-               if (!strncmp(kctl->id.name, name, sizeof(kctl->id.name)))
-                       return kctl;
-       return NULL;
+       return snd_ctl_find_id_mixer_locked(soc_card->snd_card, name);
 }
 EXPORT_SYMBOL_GPL(snd_soc_card_get_kcontrol_locked);
 
 struct snd_kcontrol *snd_soc_card_get_kcontrol(struct snd_soc_card *soc_card,
                                               const char *name)
 {
-       struct snd_card *card = soc_card->snd_card;
-       struct snd_kcontrol *kctl;
-
-       down_read(&card->controls_rwsem);
-       kctl = snd_soc_card_get_kcontrol_locked(soc_card, name);
-       up_read(&card->controls_rwsem);
+       if (unlikely(!name))
+               return NULL;
 
-       return kctl;
+       return snd_ctl_find_id_mixer(soc_card->snd_card, name);
 }
 EXPORT_SYMBOL_GPL(snd_soc_card_get_kcontrol);