/*1* Do sleep inside a spin-lock2* Copyright (c) 1999 by Takashi Iwai <[email protected]>3*4*5* This program is free software; you can redistribute it and/or modify6* it under the terms of the GNU General Public License as published by7* the Free Software Foundation; either version 2 of the License, or8* (at your option) any later version.9*10* This program is distributed in the hope that it will be useful,11* but WITHOUT ANY WARRANTY; without even the implied warranty of12* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the13* GNU General Public License for more details.14*15* You should have received a copy of the GNU General Public License16* along with this program; if not, write to the Free Software17* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA18*19*/2021#include <sound/core.h>22#include "seq_lock.h"2324#if defined(CONFIG_SMP) || defined(CONFIG_SND_DEBUG)2526/* wait until all locks are released */27void snd_use_lock_sync_helper(snd_use_lock_t *lockp, const char *file, int line)28{29int max_count = 5 * HZ;3031if (atomic_read(lockp) < 0) {32printk(KERN_WARNING "seq_lock: lock trouble [counter = %d] in %s:%d\n", atomic_read(lockp), file, line);33return;34}35while (atomic_read(lockp) > 0) {36if (max_count == 0) {37snd_printk(KERN_WARNING "seq_lock: timeout [%d left] in %s:%d\n", atomic_read(lockp), file, line);38break;39}40schedule_timeout_uninterruptible(1);41max_count--;42}43}4445EXPORT_SYMBOL(snd_use_lock_sync_helper);4647#endif484950