Branch data Line data Source code
1 : : // SPDX-License-Identifier: GPL-2.0-or-later 2 : : /* 3 : : * Do sleep inside a spin-lock 4 : : * Copyright (c) 1999 by Takashi Iwai <tiwai@suse.de> 5 : : */ 6 : : 7 : : #include <linux/export.h> 8 : : #include <sound/core.h> 9 : : #include "seq_lock.h" 10 : : 11 : : /* wait until all locks are released */ 12 : 0 : void snd_use_lock_sync_helper(snd_use_lock_t *lockp, const char *file, int line) 13 : : { 14 : 0 : int warn_count = 5 * HZ; 15 : : 16 [ # # ]: 0 : if (atomic_read(lockp) < 0) { 17 : 0 : pr_warn("ALSA: seq_lock: lock trouble [counter = %d] in %s:%d\n", atomic_read(lockp), file, line); 18 : 0 : return; 19 : : } 20 [ # # ]: 0 : while (atomic_read(lockp) > 0) { 21 [ # # ]: 0 : if (warn_count-- == 0) 22 : 0 : pr_warn("ALSA: seq_lock: waiting [%d left] in %s:%d\n", atomic_read(lockp), file, line); 23 : 0 : schedule_timeout_uninterruptible(1); 24 : : } 25 : : } 26 : : EXPORT_SYMBOL(snd_use_lock_sync_helper);