This source file includes following definitions.
- _atomic_dec_and_lock
- _atomic_dec_and_lock_irqsave
1
2 #include <linux/export.h>
3 #include <linux/spinlock.h>
4 #include <linux/atomic.h>
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 int _atomic_dec_and_lock(atomic_t *atomic, spinlock_t *lock)
22 {
23
24 if (atomic_add_unless(atomic, -1, 1))
25 return 0;
26
27
28 spin_lock(lock);
29 if (atomic_dec_and_test(atomic))
30 return 1;
31 spin_unlock(lock);
32 return 0;
33 }
34
35 EXPORT_SYMBOL(_atomic_dec_and_lock);
36
37 int _atomic_dec_and_lock_irqsave(atomic_t *atomic, spinlock_t *lock,
38 unsigned long *flags)
39 {
40
41 if (atomic_add_unless(atomic, -1, 1))
42 return 0;
43
44
45 spin_lock_irqsave(lock, *flags);
46 if (atomic_dec_and_test(atomic))
47 return 1;
48 spin_unlock_irqrestore(lock, *flags);
49 return 0;
50 }
51 EXPORT_SYMBOL(_atomic_dec_and_lock_irqsave);