seq_lock.c 744 B

1234567891011121314151617181920212223242526
  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. #include <linux/export.h>
  7. #include <sound/core.h>
  8. #include "seq_lock.h"
  9. /* wait until all locks are released */
  10. void snd_use_lock_sync_helper(snd_use_lock_t *lockp, const char *file, int line)
  11. {
  12. int warn_count = 5 * HZ;
  13. if (atomic_read(lockp) < 0) {
  14. pr_warn("ALSA: seq_lock: lock trouble [counter = %d] in %s:%d\n", atomic_read(lockp), file, line);
  15. return;
  16. }
  17. while (atomic_read(lockp) > 0) {
  18. if (warn_count-- == 0)
  19. pr_warn("ALSA: seq_lock: waiting [%d left] in %s:%d\n", atomic_read(lockp), file, line);
  20. schedule_timeout_uninterruptible(1);
  21. }
  22. }
  23. EXPORT_SYMBOL(snd_use_lock_sync_helper);