ALSA: control: Introduce unlocked version for snd_ctl_find_*() helpers
authorTakashi Iwai <tiwai@suse.de>
Tue, 18 Jul 2023 14:13:02 +0000 (16:13 +0200)
committerTakashi Iwai <tiwai@suse.de>
Thu, 20 Jul 2023 08:03:00 +0000 (10:03 +0200)
commitb1e055f67611daf098e27e8731386eeb5257bde3
treeb7a4d8ddcbbf6f83a276aada4cc25f919b873f29
parent6723670a483501497dc339ae37676525245a913a
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>
include/sound/control.h
sound/core/control.c
sound/core/control_compat.c
sound/core/control_led.c
sound/core/oss/mixer_oss.c
sound/pci/emu10k1/emufx.c