summaryrefslogtreecommitdiff
path: root/sound/core/control_compat.c
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2023-07-18 16:13:02 +0200
committerTakashi Iwai <tiwai@suse.de>2023-07-20 10:03:00 +0200
commitb1e055f67611daf098e27e8731386eeb5257bde3 (patch)
treeb7a4d8ddcbbf6f83a276aada4cc25f919b873f29 /sound/core/control_compat.c
parent6723670a483501497dc339ae37676525245a913a (diff)
ALSA: control: Introduce unlocked version for snd_ctl_find_*() helpers
For reducing the unnecessary use of controls_rwsem in the drivers, this patch adds a new variant for snd_ctl_find_*() helpers: snd_ctl_find_id_locked() and snd_ctl_find_numid_locked() look for a kctl element inside the card->controls_rwsem -- that is, doing the very same as what snd_ctl_find_id() and snd_ctl_find_numid() did until now. snd_ctl_find_id() and snd_ctl_find_numid() remain same, i.e. still unlocked version, but they will be switched to locked version once after all callers are replaced. The patch also replaces the calls of snd_ctl_find_id() and snd_ctl_find_numid() in a few places; all of those are places where we know that the functions are called properly with controls_rwsem held. All others are without rwsem (although they should have been). After this patch, we'll turn on the locking in snd_ctl_find_id() and snd_ctl_find_numid() to be more race-free. Link: https://lore.kernel.org/r/20230718141304.1032-10-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/core/control_compat.c')
-rw-r--r--sound/core/control_compat.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/sound/core/control_compat.c b/sound/core/control_compat.c
index 9cae5d74335c..0e8b1bfb040e 100644
--- a/sound/core/control_compat.c
+++ b/sound/core/control_compat.c
@@ -173,7 +173,7 @@ static int get_ctl_type(struct snd_card *card, struct snd_ctl_elem_id *id,
int err;
down_read(&card->controls_rwsem);
- kctl = snd_ctl_find_id(card, id);
+ kctl = snd_ctl_find_id_locked(card, id);
if (! kctl) {
up_read(&card->controls_rwsem);
return -ENOENT;