ALSA: seq: Use atomic ops for autoload refcount
... just to robustify for races.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
diff --git a/sound/core/seq/seq_device.c b/sound/core/seq/seq_device.c
index 91a786a..775ea93 100644
--- a/sound/core/seq/seq_device.c
+++ b/sound/core/seq/seq_device.c
@@ -127,15 +127,15 @@
#ifdef CONFIG_MODULES
/* avoid auto-loading during module_init() */
-static int snd_seq_in_init;
+static atomic_t snd_seq_in_init = ATOMIC_INIT(0);
void snd_seq_autoload_lock(void)
{
- snd_seq_in_init++;
+ atomic_inc(&snd_seq_in_init);
}
void snd_seq_autoload_unlock(void)
{
- snd_seq_in_init--;
+ atomic_dec(&snd_seq_in_init);
}
#endif
@@ -147,7 +147,7 @@
/* Calling request_module during module_init()
* may cause blocking.
*/
- if (snd_seq_in_init)
+ if (atomic_read(&snd_seq_in_init))
return;
mutex_lock(&ops_mutex);