Commit 897cc72b authored by Richard Fitzgerald's avatar Richard Fitzgerald Committed by Mark Brown

ASoC: soc-card: Use snd_ctl_find_id_mixer() instead of open-coding

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: default avatarRichard Fitzgerald <rf@opensource.cirrus.com>
Reviewed-by: default avatarTakashi Iwai <tiwai@suse.de>
Link: https://msgid.link/r/20240401100210.61277-3-rf@opensource.cirrus.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 08ea486a
......@@ -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);
......
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